Skip to content

Commit 85a7566

Browse files
Option --no-built-in-assertions
This commit changes the behahaviour of --no-assertions so that only user assertions are ignored. Built-in assertions can be hidden by the new option --no-built-in-assertions.
1 parent 32fcbbc commit 85a7566

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/analyses/goto_check.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class goto_checkt
5555
retain_trivial=_options.get_bool_option("retain-trivial");
5656
enable_assert_to_assume=_options.get_bool_option("assert-to-assume");
5757
enable_assertions=_options.get_bool_option("assertions");
58+
enable_built_in_assertions=_options.get_bool_option("built-in-assertions");
5859
enable_assumptions=_options.get_bool_option("assumptions");
5960
error_labels=_options.get_list_option("error-label");
6061
}
@@ -125,6 +126,7 @@ class goto_checkt
125126
bool retain_trivial;
126127
bool enable_assert_to_assume;
127128
bool enable_assertions;
129+
bool enable_built_in_assertions;
128130
bool enable_assumptions;
129131

130132
typedef optionst::value_listt error_labelst;
@@ -1730,9 +1732,10 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
17301732
}
17311733
else if(i.is_assert())
17321734
{
1733-
if(i.source_location.get_bool("user-provided") &&
1734-
i.source_location.get_property_class()!="error label" &&
1735-
!enable_assertions)
1735+
bool is_user_provided=i.source_location.get_bool("user-provided");
1736+
if((is_user_provided && !enable_assertions &&
1737+
i.source_location.get_property_class()!="error label") ||
1738+
(!is_user_provided && !enable_built_in_assertions))
17361739
i.type=SKIP;
17371740
}
17381741
else if(i.is_assume())

src/cbmc/cbmc_parse_options.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
237237
else
238238
options.set_option("assertions", true);
239239

240+
// check built-in assertions
241+
if(cmdline.isset("no-built-in-assertions"))
242+
options.set_option("built-in-assertions", false);
243+
else
244+
options.set_option("built-in-assertions", true);
245+
240246
// use assumptions
241247
if(cmdline.isset("no-assumptions"))
242248
options.set_option("assumptions", false);
@@ -1148,6 +1154,7 @@ void cbmc_parse_optionst::help()
11481154
"Program instrumentation options:\n"
11491155
HELP_GOTO_CHECK
11501156
" --no-assertions ignore user assertions\n"
1157+
" --no-built-in-assertions ignore assertions in built-in library\n"
11511158
" --no-assumptions ignore user assumptions\n"
11521159
" --error-label label check that label is unreachable\n"
11531160
" --cover CC create test-suite with coverage criterion CC\n" // NOLINT(*)

src/cbmc/cbmc_parse_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class optionst;
3232
"(depth):(partial-loops)(no-unwinding-assertions)(unwinding-assertions)" \
3333
OPT_GOTO_CHECK \
3434
"(no-assertions)(no-assumptions)" \
35+
"(no-built-in-assertions)" \
3536
"(xml-ui)(xml-interface)(json-ui)" \
3637
"(smt1)(smt2)(fpa)(cvc3)(cvc4)(boolector)(yices)(z3)(opensmt)(mathsat)" \
3738
"(no-sat-preprocessor)" \

src/goto-programs/builtin_functions.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,9 @@ void goto_convertt::do_function_call_symbol(
13041304
goto_programt::targett t=dest.add_instruction(ASSERT);
13051305
t->guard=arguments[0];
13061306
t->source_location=function.source_location();
1307-
t->source_location.set("user-provided", true);
1307+
t->source_location.set(
1308+
"user-provided",
1309+
!function.source_location().is_built_in());
13081310
t->source_location.set_property_class(ID_assertion);
13091311
t->source_location.set_comment(description);
13101312

0 commit comments

Comments
 (0)