File tree Expand file tree Collapse file tree 8 files changed +44
-3
lines changed
regression/cbmc/self_loops_to_assumptions1 Expand file tree Collapse file tree 8 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,11 @@ void jbmc_parse_optionst::get_command_line_options(optionst &options)
152152 else
153153 options.set_option (" propagation" , true );
154154
155+ // transform self loops to assumptions
156+ options.set_option (
157+ " self-loops-to-assumptions" ,
158+ !cmdline.isset (" no-self-loops-to-assumptions" ));
159+
155160 // all checks supported by goto_check
156161 PARSE_OPTIONS_GOTO_CHECK (cmdline, options);
157162
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --unwind 1 --unwinding-assertions
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^VERIFICATION SUCCESSFUL$
7+ --
Original file line number Diff line number Diff line change 1+ int main ()
2+ {
3+ while (1 )
4+ {
5+ }
6+
7+ return 0 ;
8+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --unwind 1 --unwinding-assertions --no-self-loops-to-assumptions
4+ ^EXIT=10$
5+ ^SIGNAL=0$
6+ ^VERIFICATION FAILED$
7+ --
Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ class bmct:public safety_checkert
8484 symex.constant_propagation =options.get_bool_option (" propagation" );
8585 symex.record_coverage =
8686 !options.get_option (" symex-coverage-report" ).empty ();
87+ symex.self_loops_to_assumptions =
88+ options.get_bool_option (" self-loops-to-assumptions" );
8789 }
8890
8991 virtual resultt run (const goto_functionst &goto_functions)
@@ -292,6 +294,7 @@ class path_explorert : public bmct
292294 " (unwinding-assertions)" \
293295 " (no-unwinding-assertions)" \
294296 " (no-pretty-names)" \
297+ " (no-self-loops-to-assumptions)" \
295298 " (partial-loops)" \
296299 " (paths):" \
297300 " (show-symex-strategies)" \
@@ -315,6 +318,8 @@ class path_explorert : public bmct
315318 " --unwinding-assertions generate unwinding assertions (cannot be\n " \
316319 " used with --cover or --partial-loops)\n " \
317320 " --partial-loops permit paths with partial loops\n " \
321+ " --no-self-loops-to-assumptions\n " \
322+ " do not simplify while(1){} to assume(0)\n " \
318323 " --no-pretty-names do not simplify identifiers\n " \
319324 " --graphml-witness filename write the witness in GraphML format to " \
320325 " filename\n " // NOLINT(*)
Original file line number Diff line number Diff line change @@ -227,6 +227,11 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
227227 if (cmdline.isset (" no-propagation" ))
228228 options.set_option (" propagation" , false );
229229
230+ // transform self loops to assumptions
231+ options.set_option (
232+ " self-loops-to-assumptions" ,
233+ !cmdline.isset (" no-self-loops-to-assumptions" ));
234+
230235 // all checks supported by goto_check
231236 PARSE_OPTIONS_GOTO_CHECK (cmdline, options);
232237
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ class goto_symext
5757 total_vccs (0 ),
5858 remaining_vccs(0 ),
5959 constant_propagation(true ),
60+ self_loops_to_assumptions(true ),
6061 language_mode(),
6162 outer_symbol_table(outer_symbol_table),
6263 ns(outer_symbol_table),
@@ -202,6 +203,7 @@ class goto_symext
202203 unsigned total_vccs, remaining_vccs;
203204
204205 bool constant_propagation;
206+ bool self_loops_to_assumptions;
205207
206208 optionst options;
207209
Original file line number Diff line number Diff line change @@ -58,9 +58,11 @@ void goto_symext::symex_goto(statet &state)
5858 if (!forward) // backwards?
5959 {
6060 // is it label: goto label; or while(cond); - popular in SV-COMP
61- if (goto_target==state.source .pc ||
62- (instruction.incoming_edges .size ()==1 &&
63- *instruction.incoming_edges .begin ()==goto_target))
61+ if (
62+ self_loops_to_assumptions &&
63+ (goto_target == state.source .pc ||
64+ (instruction.incoming_edges .size () == 1 &&
65+ *instruction.incoming_edges .begin () == goto_target)))
6466 {
6567 // generate assume(false) or a suitable negation if this
6668 // instruction is a conditional goto
You can’t perform that action at this time.
0 commit comments