Skip to content

Commit 721e65d

Browse files
author
Daniel Kroening
authored
Merge pull request #454 from thk123/refactor/generalise-show-goto-functions-flag
Replaced all instances of show-goto-functions with a define
2 parents 1c42040 + 018c401 commit 721e65d

14 files changed

+47
-40
lines changed

src/analyses/goto_check.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ void goto_check(
2929
const optionst &options,
3030
goto_modelt &goto_model);
3131

32-
#define GOTO_CHECK_OPTIONS \
32+
#define OPT_GOTO_CHECK \
3333
"(bounds-check)(pointer-check)(memory-leak-check)" \
3434
"(div-by-zero-check)(signed-overflow-check)(unsigned-overflow-check)" \
3535
"(pointer-overflow-check)(conversion-check)(undefined-shift-check)" \
3636
"(float-overflow-check)(nan-check)"
3737

38-
#define GOTO_CHECK_HELP \
38+
#define HELP_GOTO_CHECK \
3939
" --bounds-check enable array bounds checks\n" \
4040
" --pointer-check enable pointer checks\n" \
4141
" --memory-leak-check enable memory leak checks\n" \
@@ -48,7 +48,7 @@ void goto_check(
4848
" --float-overflow-check check floating-point for +/-Inf\n" \
4949
" --nan-check check floating-point for NaN\n" \
5050

51-
#define GOTO_CHECK_PARSE_OPTIONS(cmdline, options) \
51+
#define PARSE_OPTIONS_GOTO_CHECK(cmdline, options) \
5252
options.set_option("bounds-check", cmdline.isset("bounds-check")); \
5353
options.set_option("pointer-check", cmdline.isset("pointer-check")); \
5454
options.set_option("memory-leak-check", cmdline.isset("memory-leak-check")); \

src/cbmc/cbmc_parse_options.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
220220
options.set_option("propagation", true);
221221

222222
// all checks supported by goto_check
223-
GOTO_CHECK_PARSE_OPTIONS(cmdline, options);
223+
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
224224

225225
// unwind loops in java enum static initialization
226226
if(cmdline.isset("java-unwind-enum-static"))
@@ -1121,10 +1121,10 @@ void cbmc_parse_optionst::help()
11211121
"Program representations:\n"
11221122
" --show-parse-tree show parse tree\n"
11231123
" --show-symbol-table show symbol table\n"
1124-
" --show-goto-functions show goto program\n"
1124+
HELP_SHOW_GOTO_FUNCTIONS
11251125
"\n"
11261126
"Program instrumentation options:\n"
1127-
GOTO_CHECK_HELP
1127+
HELP_GOTO_CHECK
11281128
" --no-assertions ignore user assertions\n"
11291129
" --no-assumptions ignore user assumptions\n"
11301130
" --error-label label check that label is unreachable\n"

src/cbmc/cbmc_parse_options.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class optionst;
3030
"D:I:(c89)(c99)(c11)(cpp89)(cpp99)(cpp11)" \
3131
"(classpath):(cp):(main-class):" \
3232
"(depth):(partial-loops)(no-unwinding-assertions)(unwinding-assertions)" \
33-
GOTO_CHECK_OPTIONS \
33+
OPT_GOTO_CHECK \
3434
"(no-assertions)(no-assumptions)" \
3535
"(xml-ui)(xml-interface)(json-ui)" \
3636
"(smt1)(smt2)(fpa)(cvc3)(cvc4)(boolector)(yices)(z3)(opensmt)(mathsat)" \

src/clobber/clobber_parse_options.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void clobber_parse_optionst::get_command_line_options(optionst &options)
112112
options.set_option("unwindset", cmdline.get_value("unwindset"));
113113

114114
// all checks supported by goto_check
115-
GOTO_CHECK_PARSE_OPTIONS(cmdline, options);
115+
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
116116

117117
// check assertions
118118
if(cmdline.isset("no-assertions"))
@@ -425,7 +425,7 @@ bool clobber_parse_optionst::process_goto_program(
425425
// show it?
426426
if(cmdline.isset("show-goto-functions"))
427427
{
428-
goto_functions.output(ns, std::cout);
428+
show_goto_functions(ns, get_ui(), goto_functions);
429429
return true;
430430
}
431431
}
@@ -655,7 +655,7 @@ void clobber_parse_optionst::help()
655655
" --unsigned-char make \"char\" unsigned by default\n"
656656
" --show-parse-tree show parse tree\n"
657657
" --show-symbol-table show symbol table\n"
658-
" --show-goto-functions show goto program\n"
658+
HELP_SHOW_GOTO_FUNCTIONS
659659
" --ppc-macos set MACOS/PPC architecture\n"
660660
" --mm model set memory model (default: sc)\n"
661661
" --arch set architecture (default: "
@@ -673,7 +673,7 @@ void clobber_parse_optionst::help()
673673
" --round-to-zero IEEE floating point rounding mode\n"
674674
"\n"
675675
"Program instrumentation options:\n"
676-
GOTO_CHECK_HELP
676+
HELP_GOTO_CHECK
677677
" --show-properties show the properties\n"
678678
" --no-assertions ignore user assertions\n"
679679
" --no-assumptions ignore user assumptions\n"

src/clobber/clobber_parse_options.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ Author: Daniel Kroening, [email protected]
1515
#include <langapi/language_ui.h>
1616

1717
#include <analyses/goto_check.h>
18+
#include <goto-programs/show_goto_functions.h>
1819

1920
class goto_functionst;
2021
class optionst;
2122

2223
#define CLOBBER_OPTIONS \
2324
"(depth):(context-bound):(unwind):" \
24-
GOTO_CHECK_OPTIONS \
25+
OPT_GOTO_CHECK \
26+
OPT_SHOW_GOTO_FUNCTIONS \
2527
"(no-assertions)(no-assumptions)" \
2628
"(error-label):(verbosity):(no-library)" \
2729
"(version)" \

src/goto-analyzer/goto_analyzer_parse_options.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,7 @@ bool goto_analyzer_parse_optionst::process_goto_program(
406406
// show it?
407407
if(cmdline.isset("show-goto-functions"))
408408
{
409-
namespacet ns(goto_model.symbol_table);
410-
411-
goto_model.goto_functions.output(ns, std::cout);
409+
show_goto_functions(goto_model, get_ui());
412410
return true;
413411
}
414412

@@ -521,7 +519,7 @@ void goto_analyzer_parse_optionst::help()
521519
"Program representations:\n"
522520
" --show-parse-tree show parse tree\n"
523521
" --show-symbol-table show symbol table\n"
524-
" --show-goto-functions show goto program\n"
522+
HELP_SHOW_GOTO_FUNCTIONS
525523
" --show-properties show the properties, but don't run analysis\n"
526524
"\n"
527525
"Other options:\n"

src/goto-analyzer/goto_analyzer_parse_options.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
1515
#include <langapi/language_ui.h>
1616

1717
#include <goto-programs/get_goto_model.h>
18+
#include <goto-programs/show_goto_functions.h>
1819

1920
class bmct;
2021
class goto_functionst;
@@ -26,7 +27,8 @@ class optionst;
2627
"(classpath):(cp):(main-class):" \
2728
"(16)(32)(64)(LP64)(ILP64)(LLP64)(ILP32)(LP32)" \
2829
"(little-endian)(big-endian)" \
29-
"(show-goto-functions)(show-loops)" \
30+
OPT_SHOW_GOTO_FUNCTIONS \
31+
"(show-loops)" \
3032
"(show-symbol-table)(show-parse-tree)" \
3133
"(show-properties)(show-reachable-properties)(property):" \
3234
"(verbosity):(version)" \

src/goto-diff/goto_diff_parse_options.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,8 @@ int goto_diff_parse_optionst::doit()
334334

335335
if(cmdline.isset("show-goto-functions"))
336336
{
337-
//ENHANCE: make UI specific
338-
std::cout << "*******************************************************\n";
339-
namespacet ns1(goto_model1.symbol_table);
340-
goto_model1.goto_functions.output(ns1, std::cout);
341-
std::cout << "*******************************************************\n";
342-
namespacet ns2(goto_model2.symbol_table);
343-
goto_model2.goto_functions.output(ns2, std::cout);
337+
show_goto_functions(goto_model1, get_ui());
338+
show_goto_functions(goto_model2, get_ui());
344339
return 0;
345340
}
346341

@@ -512,7 +507,7 @@ bool goto_diff_parse_optionst::process_goto_program(
512507
// show it?
513508
if(cmdline.isset("show-goto-functions"))
514509
{
515-
goto_functions.output(ns, std::cout);
510+
show_goto_functions(ns, get_ui(), goto_functions);
516511
return true;
517512
}
518513
}
@@ -569,7 +564,7 @@ void goto_diff_parse_optionst::help()
569564
" goto_diff old new goto binaries to be compared\n"
570565
"\n"
571566
"Diff options:\n"
572-
" --show-functions show functions (default)\n"
567+
HELP_SHOW_GOTO_FUNCTIONS
573568
" --syntactic do syntactic diff (default)\n"
574569
" -u | --unified output unified diff\n"
575570
" --change-impact | \n"

src/goto-diff/goto_diff_parse_options.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Peter Schrammel
1515
#include <langapi/language_ui.h>
1616

1717
#include <goto-programs/goto_model.h>
18+
#include <goto-programs/show_goto_functions.h>
1819

1920
#include "goto_diff_languages.h"
2021

@@ -23,7 +24,7 @@ class optionst;
2324

2425
#define GOTO_DIFF_OPTIONS \
2526
"(json-ui)" \
26-
"(show-goto-functions)" \
27+
OPT_SHOW_GOTO_FUNCTIONS \
2728
"(verbosity):(version)" \
2829
"u(unified)(change-impact)(forward-impact)(backward-impact)" \
2930
"(compact-output)"

src/goto-instrument/goto_instrument_parse_options.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ int goto_instrument_parse_optionst::doit()
575575
if(cmdline.isset("show-goto-functions"))
576576
{
577577
namespacet ns(symbol_table);
578-
goto_functions.output(ns, std::cout);
578+
show_goto_functions(ns, get_ui(), goto_functions);
579579
return 0;
580580
}
581581

@@ -884,7 +884,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
884884
options.set_option("assert-to-assume", false);
885885

886886
// all checks supported by goto_check
887-
GOTO_CHECK_PARSE_OPTIONS(cmdline, options);
887+
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
888888

889889
// check assertions
890890
if(cmdline.isset("no-assertions"))
@@ -1456,14 +1456,14 @@ void goto_instrument_parse_optionst::help()
14561456
" --show-properties show the properties\n"
14571457
" --show-symbol-table show symbol table\n"
14581458
" --list-symbols list symbols with type information\n"
1459-
" --show-goto-functions show goto program\n"
1459+
HELP_SHOW_GOTO_FUNCTIONS
14601460
" --list-undefined-functions list functions without body\n"
14611461
" --show-struct-alignment show struct members that might be concurrently accessed\n" // NOLINT(*)
14621462
" --show-natural-loops show natural loop heads\n"
14631463
"\n"
14641464
"Safety checks:\n"
14651465
" --no-assertions ignore user assertions\n"
1466-
GOTO_CHECK_HELP
1466+
HELP_GOTO_CHECK
14671467
" --uninitialized-check add checks for uninitialized locals (experimental)\n" // NOLINT(*)
14681468
" --error-label label check that label is unreachable\n"
14691469
" --stack-depth n add check that call stack size of non-inlined functions never exceeds n\n" // NOLINT(*)

src/goto-instrument/goto_instrument_parse_options.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <langapi/language_ui.h>
1616
#include <goto-programs/goto_functions.h>
17+
#include <goto-programs/show_goto_functions.h>
1718

1819
#include <analyses/goto_check.h>
1920

@@ -22,7 +23,7 @@ Author: Daniel Kroening, [email protected]
2223
"(document-claims-latex)(document-claims-html)" \
2324
"(document-properties-latex)(document-properties-html)" \
2425
"(dump-c)(dump-cpp)(use-system-headers)(dot)(xml)" \
25-
GOTO_CHECK_OPTIONS \
26+
OPT_GOTO_CHECK \
2627
/* no-X-check are deprecated and ignored */ \
2728
"(no-bounds-check)(no-pointer-check)(no-div-by-zero-check)" \
2829
"(no-nan-check)" \
@@ -43,7 +44,8 @@ Author: Daniel Kroening, [email protected]
4344
"(nondet-volatile)(isr):" \
4445
"(stack-depth):(nondet-static)" \
4546
"(function-enter):(function-exit):(branch):" \
46-
"(show-goto-functions)(show-value-sets)" \
47+
OPT_SHOW_GOTO_FUNCTIONS \
48+
"(show-value-sets)" \
4749
"(show-global-may-alias)" \
4850
"(show-local-bitvector-analysis)(show-custom-bitvector-analysis)" \
4951
"(show-escape-analysis)(escape-analysis)" \

src/goto-programs/show_goto_functions.h

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ class goto_functionst;
1515
class namespacet;
1616
class goto_modelt;
1717

18+
#define OPT_SHOW_GOTO_FUNCTIONS \
19+
"(show-goto-functions)"
20+
21+
#define HELP_SHOW_GOTO_FUNCTIONS \
22+
" --show-goto-functions show goto program\n"
23+
1824
void show_goto_functions(
1925
const namespacet &ns,
2026
ui_message_handlert::uit ui,

src/symex/symex_parse_options.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void symex_parse_optionst::get_command_line_options(optionst &options)
119119
options.set_option("unwindset", cmdline.get_value("unwindset"));
120120

121121
// all checks supported by goto_check
122-
GOTO_CHECK_PARSE_OPTIONS(cmdline, options);
122+
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
123123

124124
// check assertions
125125
if(cmdline.isset("no-assertions"))
@@ -409,8 +409,7 @@ bool symex_parse_optionst::process_goto_program(const optionst &options)
409409
// show it?
410410
if(cmdline.isset("show-goto-functions"))
411411
{
412-
const namespacet ns(goto_model.symbol_table);
413-
goto_model.goto_functions.output(ns, std::cout);
412+
show_goto_functions(goto_model, get_ui());
414413
return true;
415414
}
416415
}
@@ -677,7 +676,7 @@ void symex_parse_optionst::help()
677676
" --unsigned-char make \"char\" unsigned by default\n"
678677
" --show-parse-tree show parse tree\n"
679678
" --show-symbol-table show symbol table\n"
680-
" --show-goto-functions show goto program\n"
679+
HELP_SHOW_GOTO_FUNCTIONS
681680
" --ppc-macos set MACOS/PPC architecture\n"
682681
" --mm model set memory model (default: sc)\n"
683682
" --arch set architecture (default: "
@@ -696,7 +695,7 @@ void symex_parse_optionst::help()
696695
" --function name set main function name\n"
697696
"\n"
698697
"Program instrumentation options:\n"
699-
GOTO_CHECK_HELP
698+
HELP_GOTO_CHECK
700699
" --no-assertions ignore user assertions\n"
701700
" --no-assumptions ignore user assumptions\n"
702701
" --error-label label check that label is unreachable\n"

src/symex/symex_parse_options.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/parse_options.h>
1414

1515
#include <goto-programs/get_goto_model.h>
16+
#include <goto-programs/show_goto_functions.h>
1617

1718
#include <langapi/language_ui.h>
1819

@@ -27,7 +28,7 @@ class optionst;
2728
"(function):" \
2829
"D:I:" \
2930
"(depth):(context-bound):(branch-bound):(unwind):" \
30-
GOTO_CHECK_OPTIONS \
31+
OPT_GOTO_CHECK \
3132
"(no-assertions)(no-assumptions)" \
3233
"(16)(32)(64)(LP64)(ILP64)(LLP64)(ILP32)(LP32)" \
3334
"(little-endian)(big-endian)" \
@@ -39,7 +40,8 @@ class optionst;
3940
"(ppc-macos)(unsigned-char)" \
4041
"(string-abstraction)(no-arch)(arch):(floatbv)(fixedbv)" \
4142
"(round-to-nearest)(round-to-plus-inf)(round-to-minus-inf)(round-to-zero)" \
42-
"(show-locs)(show-vcc)(show-properties)(show-goto-functions)" \
43+
"(show-locs)(show-vcc)(show-properties)" \
44+
OPT_SHOW_GOTO_FUNCTIONS \
4345
"(property):(trace)(show-trace)(stop-on-fail)(eager-infeasibility)" \
4446
"(no-simplify)(no-unwinding-assertions)(no-propagation)"
4547
// the last line is for CBMC-regression testing only

0 commit comments

Comments
 (0)