Skip to content

Commit 71a42d7

Browse files
author
martin
committed
Add options that goto-check uses to the macros
goto-check makes use of the options assertions, assumptions, assert-to-assume and retain-trivial. These were handled to different degrees and in different way in each of the tools. This commit adds these options to the set of options in the *_GOTO_CHECK macros. This reduces the amount of duplication and parallel maintenance.
1 parent 7f14ebb commit 71a42d7

7 files changed

+21
-83
lines changed

src/analyses/goto_check.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ void goto_check(
3939
"overflow-check)" \
4040
"(pointer-overflow-check)(conversion-check)(undefined-shift-check)" \
4141
"(float-overflow-check)(nan-check)(no-built-in-assertions)" \
42-
"(pointer-primitive-check)"
42+
"(pointer-primitive-check)(error-label):" \
43+
"(no-assertions)(no-assumptions)" \
44+
"(assert-to-assume)(retain-trivial)"
4345

4446
// clang-format off
4547
#define HELP_GOTO_CHECK \
@@ -54,9 +56,15 @@ void goto_check(
5456
" --undefined-shift-check check shift greater than bit-width\n" \
5557
" --float-overflow-check check floating-point for +/-Inf\n" \
5658
" --nan-check check floating-point for NaN\n" \
57-
" --no-built-in-assertions ignore assertions in built-in library\n" \
5859
" --enum-range-check checks that all enum type expressions have values in the enum range\n" /* NOLINT(whitespace/line_length) */ \
59-
" --pointer-primitive-check checks that all pointers in pointer primitives are valid or null\n" /* NOLINT(whitespace/line_length) */
60+
" --pointer-primitive-check checks that all pointers in pointer primitives are valid or null\n" /* NOLINT(whitespace/line_length) */ \
61+
" --error-label label check that label is unreachable\n" \
62+
" --no-built-in-assertions ignore assertions in built-in library\n" \
63+
" --no-assertions ignore user assertions\n" \
64+
" --no-assumptions ignore user assumptions\n" \
65+
" --assert-to-assume convert user assertions to assumptions\n" \
66+
" --retain-trivial keep checks which are obviously true\n" \
67+
6068

6169
#define PARSE_OPTIONS_GOTO_CHECK(cmdline, options) \
6270
options.set_option("bounds-check", cmdline.isset("bounds-check")); \
@@ -72,7 +80,13 @@ void goto_check(
7280
options.set_option("float-overflow-check", cmdline.isset("float-overflow-check")); /* NOLINT(whitespace/line_length) */ \
7381
options.set_option("nan-check", cmdline.isset("nan-check")); \
7482
options.set_option("built-in-assertions", !cmdline.isset("no-built-in-assertions")); /* NOLINT(whitespace/line_length) */ \
75-
options.set_option("pointer-primitive-check", cmdline.isset("pointer-primitive-check")) /* NOLINT(whitespace/line_length) */
83+
options.set_option("pointer-primitive-check", cmdline.isset("pointer-primitive-check")); /* NOLINT(whitespace/line_length) */ \
84+
options.set_option("assertions", !cmdline.isset("no-assertions")); /* NOLINT(whitespace/line_length) */ \
85+
options.set_option("assumptions", !cmdline.isset("no-assumptions")); /* NOLINT(whitespace/line_length) */ \
86+
options.set_option("assert-to-assume", cmdline.isset("assert-to-assume")); /* NOLINT(whitespace/line_length) */ \
87+
options.set_option("retain-trivial", cmdline.isset("retain-trivial")); /* NOLINT(whitespace/line_length) */ \
88+
if(cmdline.isset("error-label")) \
89+
options.set_option("error-label", cmdline.get_values("error-label")) \
7690
// clang-format on
7791

7892
#endif // CPROVER_ANALYSES_GOTO_CHECK_H

src/cbmc/cbmc_parse_options.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ ::cbmc_parse_optionst::cbmc_parse_optionst(
114114
void cbmc_parse_optionst::set_default_options(optionst &options)
115115
{
116116
// Default true
117-
options.set_option("assertions", true);
118-
options.set_option("assumptions", true);
119117
options.set_option("built-in-assertions", true);
120118
options.set_option("pretty-names", true);
121119
options.set_option("propagation", true);
@@ -313,18 +311,6 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
313311
// all checks supported by goto_check
314312
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
315313

316-
// check assertions
317-
if(cmdline.isset("no-assertions"))
318-
options.set_option("assertions", false);
319-
320-
// use assumptions
321-
if(cmdline.isset("no-assumptions"))
322-
options.set_option("assumptions", false);
323-
324-
// magic error label
325-
if(cmdline.isset("error-label"))
326-
options.set_option("error-label", cmdline.get_values("error-label"));
327-
328314
// generate unwinding assertions
329315
if(cmdline.isset("unwinding-assertions"))
330316
{
@@ -1135,9 +1121,6 @@ void cbmc_parse_optionst::help()
11351121
"\n"
11361122
"Program instrumentation options:\n"
11371123
HELP_GOTO_CHECK
1138-
" --no-assertions ignore user assertions\n"
1139-
" --no-assumptions ignore user assumptions\n"
1140-
" --error-label label check that label is unreachable\n"
11411124
HELP_COVER
11421125
" --mm MM memory consistency model for concurrent programs\n" // NOLINT(*)
11431126
// NOLINTNEXTLINE(whitespace/line_length)

src/cbmc/cbmc_parse_options.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class optionst;
5353
"D:I:(c89)(c99)(c11)(cpp98)(cpp03)(cpp11)" \
5454
"(object-bits):" \
5555
OPT_GOTO_CHECK \
56-
"(no-assertions)(no-assumptions)" \
5756
"(malloc-fail-assert)(malloc-fail-null)" \
5857
"(malloc-may-fail)" \
5958
OPT_XML_INTERFACE \
@@ -73,7 +72,7 @@ class optionst;
7372
"(drop-unused-functions)" \
7473
"(havoc-undefined-functions)" \
7574
"(property):(stop-on-fail)(trace)" \
76-
"(error-label):(verbosity):(no-library)" \
75+
"(verbosity):(no-library)" \
7776
"(nondet-static)" \
7877
"(version)" \
7978
OPT_COVER \

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,6 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
131131
config.cpp.set_cpp11();
132132
#endif
133133

134-
#if 0
135-
// check assertions
136-
if(cmdline.isset("no-assertions"))
137-
options.set_option("assertions", false);
138-
else
139-
options.set_option("assertions", true);
140-
141-
// use assumptions
142-
if(cmdline.isset("no-assumptions"))
143-
options.set_option("assumptions", false);
144-
else
145-
options.set_option("assumptions", true);
146-
147-
// magic error label
148-
if(cmdline.isset("error-label"))
149-
options.set_option("error-label", cmdline.get_values("error-label"));
150-
#endif
151-
152134
// all checks supported by goto_check
153135
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
154136

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,6 @@ void goto_diff_parse_optionst::get_command_line_options(optionst &options)
133133
// all checks supported by goto_check
134134
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
135135

136-
// check assertions
137-
if(cmdline.isset("no-assertions"))
138-
options.set_option("assertions", false);
139-
else
140-
options.set_option("assertions", true);
141-
142-
// use assumptions
143-
if(cmdline.isset("no-assumptions"))
144-
options.set_option("assumptions", false);
145-
else
146-
options.set_option("assumptions", true);
147-
148-
// magic error label
149-
if(cmdline.isset("error-label"))
150-
options.set_option("error-label", cmdline.get_values("error-label"));
151-
152136
// generate unwinding assertions
153137
if(cmdline.isset("cover"))
154138
options.set_option("unwinding-assertions", false);

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,31 +1010,9 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10101010
else
10111011
options.set_option("simplify", true);
10121012

1013-
// use assumptions instead of assertions?
1014-
if(cmdline.isset("assert-to-assume"))
1015-
options.set_option("assert-to-assume", true);
1016-
else
1017-
options.set_option("assert-to-assume", false);
1018-
10191013
// all checks supported by goto_check
10201014
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
10211015

1022-
// check assertions
1023-
if(cmdline.isset("no-assertions"))
1024-
options.set_option("assertions", false);
1025-
else
1026-
options.set_option("assertions", true);
1027-
1028-
// use assumptions
1029-
if(cmdline.isset("no-assumptions"))
1030-
options.set_option("assumptions", false);
1031-
else
1032-
options.set_option("assumptions", true);
1033-
1034-
// magic error label
1035-
if(cmdline.isset("error-label"))
1036-
options.set_option("error-label", cmdline.get_value("error-label"));
1037-
10381016
// unwind loops
10391017
if(cmdline.isset("unwind"))
10401018
{
@@ -1806,7 +1784,6 @@ void goto_instrument_parse_optionst::help()
18061784
" --no-assertions ignore user assertions\n"
18071785
HELP_GOTO_CHECK
18081786
" --uninitialized-check add checks for uninitialized locals (experimental)\n" // NOLINT(*)
1809-
" --error-label label check that label is unreachable\n"
18101787
" --stack-depth n add check that call stack size of non-inlined functions never exceeds n\n" // NOLINT(*)
18111788
" --race-check add floating-point data race checks\n"
18121789
"\n"

src/goto-instrument/goto_instrument_parse_options.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ Author: Daniel Kroening, [email protected]
5252
"(no-nan-check)" \
5353
"(remove-pointers)" \
5454
"(no-simplify)" \
55-
"(assert-to-assume)" \
56-
"(no-assertions)(no-assumptions)(uninitialized-check)" \
55+
"(uninitialized-check)" \
5756
"(race-check)(scc)(one-event-per-cycle)" \
5857
"(minimum-interference)" \
5958
"(mm):(my-events)" \
@@ -92,7 +91,7 @@ Author: Daniel Kroening, [email protected]
9291
"(cav11)" \
9392
OPT_TIMESTAMP \
9493
"(show-natural-loops)(show-lexical-loops)(accelerate)(havoc-loops)" \
95-
"(error-label):(string-abstraction)" \
94+
"(string-abstraction)" \
9695
"(verbosity):(version)(xml-ui)(json-ui)(show-loops)" \
9796
"(accelerate)(constant-propagator)" \
9897
"(k-induction):(step-case)(base-case)" \

0 commit comments

Comments
 (0)