File tree 9 files changed +35
-11
lines changed
9 files changed +35
-11
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ class goto_checkt
55
55
retain_trivial=_options.get_bool_option (" retain-trivial" );
56
56
enable_assert_to_assume=_options.get_bool_option (" assert-to-assume" );
57
57
enable_assertions=_options.get_bool_option (" assertions" );
58
+ enable_built_in_assertions=_options.get_bool_option (" built-in-assertions" );
58
59
enable_assumptions=_options.get_bool_option (" assumptions" );
59
60
error_labels=_options.get_list_option (" error-label" );
60
61
}
@@ -125,6 +126,7 @@ class goto_checkt
125
126
bool retain_trivial;
126
127
bool enable_assert_to_assume;
127
128
bool enable_assertions;
129
+ bool enable_built_in_assertions;
128
130
bool enable_assumptions;
129
131
130
132
typedef optionst::value_listt error_labelst;
@@ -1730,9 +1732,10 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
1730
1732
}
1731
1733
else if (i.is_assert ())
1732
1734
{
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))
1736
1739
i.type =SKIP;
1737
1740
}
1738
1741
else if (i.is_assume ())
Original file line number Diff line number Diff line change @@ -237,6 +237,12 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
237
237
else
238
238
options.set_option (" assertions" , true );
239
239
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
+
240
246
// use assumptions
241
247
if (cmdline.isset (" no-assumptions" ))
242
248
options.set_option (" assumptions" , false );
@@ -1142,6 +1148,7 @@ void cbmc_parse_optionst::help()
1142
1148
" Program instrumentation options:\n "
1143
1149
HELP_GOTO_CHECK
1144
1150
" --no-assertions ignore user assertions\n "
1151
+ " --no-built-in-assertions ignore assertions in built-in library\n "
1145
1152
" --no-assumptions ignore user assumptions\n "
1146
1153
" --error-label label check that label is unreachable\n "
1147
1154
" --cover CC create test-suite with coverage criterion CC\n " // NOLINT(*)
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ class optionst;
32
32
" (depth):(partial-loops)(no-unwinding-assertions)(unwinding-assertions)" \
33
33
OPT_GOTO_CHECK \
34
34
" (no-assertions)(no-assumptions)" \
35
+ " (no-built-in-assertions)" \
35
36
" (xml-ui)(xml-interface)(json-ui)" \
36
37
" (smt1)(smt2)(fpa)(cvc3)(cvc4)(boolector)(yices)(z3)(opensmt)(mathsat)" \
37
38
" (no-sat-preprocessor)" \
Original file line number Diff line number Diff line change @@ -318,7 +318,7 @@ void symex_coveraget::compute_overall_coverage(
318
318
it!=file_records.end ();
319
319
++it)
320
320
{
321
- if (has_prefix (id2string (it->first ), " <builtin- " ))
321
+ if (source_locationt::is_built_in (id2string (it->first )))
322
322
continue ;
323
323
324
324
const coverage_recordt &f_cov=it->second ;
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ static void collect_eloc(
44
44
const irep_idt &file=it->source_location .get_file ();
45
45
46
46
if (!file.empty () &&
47
- !has_prefix ( id2string (file), " <built-in- " ))
47
+ !it-> source_location . is_built_in ( ))
48
48
files[file].insert (it->source_location .get_line ());
49
49
}
50
50
}
Original file line number Diff line number Diff line change @@ -1082,9 +1082,7 @@ void instrument_cover_goals(
1082
1082
1083
1083
// ignore if built-in library
1084
1084
if (!goto_program.instructions .empty () &&
1085
- has_prefix (
1086
- id2string (goto_program.instructions .front ().source_location .get_file ()),
1087
- " <builtin-library-" ))
1085
+ goto_program.instructions .front ().source_location .is_built_in ())
1088
1086
return ;
1089
1087
1090
1088
const irep_idt coverage_criterion=as_string (criterion);
Original file line number Diff line number Diff line change @@ -1320,7 +1320,9 @@ void goto_convertt::do_function_call_symbol(
1320
1320
goto_programt::targett t=dest.add_instruction (ASSERT);
1321
1321
t->guard =arguments[0 ];
1322
1322
t->source_location =function.source_location ();
1323
- t->source_location .set (" user-provided" , true );
1323
+ t->source_location .set (
1324
+ " user-provided" ,
1325
+ !function.source_location ().is_built_in ());
1324
1326
t->source_location .set_property_class (ID_assertion);
1325
1327
t->source_location .set_comment (description);
1326
1328
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
196
196
(it->is_goto () && it->pc ->guard .is_true ()) ||
197
197
source_location.is_nil () ||
198
198
source_location.get_file ().empty () ||
199
- source_location.get_file ()== " <built-in-additions> " ||
199
+ source_location.is_built_in () ||
200
200
source_location.get_line ().empty ())
201
201
{
202
202
step_to_node[it->step_nr ]=sink;
@@ -392,7 +392,7 @@ void graphml_witnesst::operator()(const symex_target_equationt &equation)
392
392
(!it->is_assignment () && !it->is_goto () && !it->is_assert ()) ||
393
393
(it->is_goto () && it->source .pc ->guard .is_true ()) ||
394
394
source_location.is_nil () ||
395
- source_location.get_file ()== " <built-in-additions> " ||
395
+ source_location.is_built_in () ||
396
396
source_location.get_line ().empty ())
397
397
{
398
398
step_to_node[step_nr]=sink;
Original file line number Diff line number Diff line change 10
10
#define CPROVER_UTIL_SOURCE_LOCATION_H
11
11
12
12
#include " irep.h"
13
+ #include " prefix.h"
13
14
14
15
class source_locationt :public irept
15
16
{
@@ -138,6 +139,18 @@ class source_locationt:public irept
138
139
return get_bool (ID_hide);
139
140
}
140
141
142
+ static bool is_built_in (const std::string &s)
143
+ {
144
+ std::string built_in1=" <built-in-" ; // "<built-in-additions>";
145
+ std::string built_in2=" <builtin-" ; // "<builtin-architecture-strings>";
146
+ return has_prefix (s, built_in1) || has_prefix (s, built_in2);
147
+ }
148
+
149
+ bool is_built_in () const
150
+ {
151
+ return is_built_in (id2string (get_file ()));
152
+ }
153
+
141
154
static const source_locationt &nil ()
142
155
{
143
156
return static_cast <const source_locationt &>(get_nil_irep ());
You can’t perform that action at this time.
0 commit comments