File tree Expand file tree Collapse file tree 9 files changed +35
-11
lines changed
Expand file tree Collapse file tree 9 files changed +35
-11
lines changed Original file line number Diff line number Diff 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 ())
Original file line number Diff line number Diff 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 );
@@ -1142,6 +1148,7 @@ void cbmc_parse_optionst::help()
11421148 " Program instrumentation options:\n "
11431149 HELP_GOTO_CHECK
11441150 " --no-assertions ignore user assertions\n "
1151+ " --no-built-in-assertions ignore assertions in built-in library\n "
11451152 " --no-assumptions ignore user assumptions\n "
11461153 " --error-label label check that label is unreachable\n "
11471154 " --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;
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)" \
Original file line number Diff line number Diff line change @@ -318,7 +318,7 @@ void symex_coveraget::compute_overall_coverage(
318318 it!=file_records.end ();
319319 ++it)
320320 {
321- if (has_prefix (id2string (it->first ), " <builtin- " ))
321+ if (source_locationt::is_built_in (id2string (it->first )))
322322 continue ;
323323
324324 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(
4444 const irep_idt &file=it->source_location .get_file ();
4545
4646 if (!file.empty () &&
47- !has_prefix ( id2string (file), " <built-in- " ))
47+ !it-> source_location . is_built_in ( ))
4848 files[file].insert (it->source_location .get_line ());
4949 }
5050 }
Original file line number Diff line number Diff line change @@ -1082,9 +1082,7 @@ void instrument_cover_goals(
10821082
10831083 // ignore if built-in library
10841084 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 ())
10881086 return ;
10891087
10901088 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(
13201320 goto_programt::targett t=dest.add_instruction (ASSERT);
13211321 t->guard =arguments[0 ];
13221322 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 ());
13241326 t->source_location .set_property_class (ID_assertion);
13251327 t->source_location .set_comment (description);
13261328
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
196196 (it->is_goto () && it->pc ->guard .is_true ()) ||
197197 source_location.is_nil () ||
198198 source_location.get_file ().empty () ||
199- source_location.get_file ()== " <built-in-additions> " ||
199+ source_location.is_built_in () ||
200200 source_location.get_line ().empty ())
201201 {
202202 step_to_node[it->step_nr ]=sink;
@@ -392,7 +392,7 @@ void graphml_witnesst::operator()(const symex_target_equationt &equation)
392392 (!it->is_assignment () && !it->is_goto () && !it->is_assert ()) ||
393393 (it->is_goto () && it->source .pc ->guard .is_true ()) ||
394394 source_location.is_nil () ||
395- source_location.get_file ()== " <built-in-additions> " ||
395+ source_location.is_built_in () ||
396396 source_location.get_line ().empty ())
397397 {
398398 step_to_node[step_nr]=sink;
Original file line number Diff line number Diff line change 1010#define CPROVER_UTIL_SOURCE_LOCATION_H
1111
1212#include " irep.h"
13+ #include " prefix.h"
1314
1415class source_locationt :public irept
1516{
@@ -138,6 +139,18 @@ class source_locationt:public irept
138139 return get_bool (ID_hide);
139140 }
140141
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+
141154 static const source_locationt &nil ()
142155 {
143156 return static_cast <const source_locationt &>(get_nil_irep ());
You can’t perform that action at this time.
0 commit comments