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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 4 additions & 9 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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(*)

0 commit comments

Comments
 (0)