File tree 10 files changed +43
-47
lines changed
cbmc-concurrency/recursion1
goto-instrument/unwind-assert2 10 files changed +43
-47
lines changed Original file line number Diff line number Diff line change @@ -244,14 +244,6 @@ void jbmc_parse_optionst::get_command_line_options(optionst &options)
244
244
" partial-loops" ,
245
245
cmdline.isset (" partial-loops" ));
246
246
247
- if (options.get_bool_option (" partial-loops" ) &&
248
- options.get_bool_option (" unwinding-assertions" ))
249
- {
250
- log .error () << " --partial-loops and --unwinding-assertions "
251
- << " must not be given together" << messaget::eom;
252
- exit (1 ); // should contemplate EX_USAGE from sysexits.h
253
- }
254
-
255
247
// remove unused equations
256
248
options.set_option (
257
249
" slice-formula" ,
Original file line number Diff line number Diff line change 1
1
CORE
2
2
main.c
3
- --unwind 1 --partial-loops --depth 100
3
+ --unwind 1 --partial-loops --unwinding-assertion -- depth 100
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
6
^VERIFICATION FAILED$
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --unwind 9 --unwinding-assertions --partial-loops
4
+ ^\[main.assertion.1\] line 6 fails when fully unwinding the loop: FAILURE$
5
+ ^\*\* 2 of 2 failed
6
+ ^EXIT=10$
7
+ ^SIGNAL=0$
8
+ ^VERIFICATION FAILED$
9
+ --
10
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -159,14 +159,6 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
159
159
options.set_option (" no-array-field-sensitivity" , true );
160
160
}
161
161
162
- if (cmdline.isset (" partial-loops" ) && cmdline.isset (" unwinding-assertions" ))
163
- {
164
- log .error ()
165
- << " --partial-loops and --unwinding-assertions must not be given "
166
- << " together" << messaget::eom;
167
- exit (CPROVER_EXIT_USAGE_ERROR);
168
- }
169
-
170
162
if (cmdline.isset (" reachability-slice" ) &&
171
163
cmdline.isset (" reachability-slice-fb" ))
172
164
{
Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ void run_property_decider(
234
234
" --show-vcc show the verification conditions\n " \
235
235
" --slice-formula remove assignments unrelated to property\n " \
236
236
" --unwinding-assertions generate unwinding assertions (cannot be\n " \
237
- " used with --cover or --partial-loops )\n " \
237
+ " used with --cover)\n " \
238
238
" --partial-loops permit paths with partial loops\n " \
239
239
" --no-self-loops-to-assumptions\n " \
240
240
" do not simplify while(1){} to assume(0)\n " \
Original file line number Diff line number Diff line change @@ -184,17 +184,26 @@ int goto_instrument_parse_optionst::doit()
184
184
bool unwinding_assertions=cmdline.isset (" unwinding-assertions" );
185
185
bool partial_loops=cmdline.isset (" partial-loops" );
186
186
bool continue_as_loops=cmdline.isset (" continue-as-loops" );
187
-
188
- if (unwinding_assertions+partial_loops+continue_as_loops>1 )
189
- throw " more than one of --unwinding-assertions,--partial-loops,"
190
- " --continue-as-loops selected" ;
187
+ if (continue_as_loops)
188
+ {
189
+ if (unwinding_assertions)
190
+ {
191
+ throw " unwinding assertions cannot be used with "
192
+ " --continue-as-loops" ;
193
+ }
194
+ else if (partial_loops)
195
+ throw " partial loops cannot be used with --continue-as-loops" ;
196
+ }
191
197
192
198
goto_unwindt::unwind_strategyt unwind_strategy=
193
199
goto_unwindt::unwind_strategyt::ASSUME;
194
200
195
201
if (unwinding_assertions)
196
202
{
197
- unwind_strategy = goto_unwindt::unwind_strategyt::ASSERT_ASSUME;
203
+ if (partial_loops)
204
+ unwind_strategy = goto_unwindt::unwind_strategyt::ASSERT_PARTIAL;
205
+ else
206
+ unwind_strategy = goto_unwindt::unwind_strategyt::ASSERT_ASSUME;
198
207
}
199
208
else if (partial_loops)
200
209
{
Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ void goto_unwindt::unwind(
130
130
{
131
131
PRECONDITION (
132
132
unwind_strategy == unwind_strategyt::ASSERT_ASSUME ||
133
+ unwind_strategy == unwind_strategyt::ASSERT_PARTIAL ||
133
134
unwind_strategy == unwind_strategyt::ASSUME);
134
135
135
136
goto_programt::const_targett t=loop_exit;
@@ -148,7 +149,9 @@ void goto_unwindt::unwind(
148
149
exit_cond = loop_head->get_condition ();
149
150
}
150
151
151
- if (unwind_strategy == unwind_strategyt::ASSERT_ASSUME)
152
+ if (
153
+ unwind_strategy == unwind_strategyt::ASSERT_ASSUME ||
154
+ unwind_strategy == unwind_strategyt::ASSERT_PARTIAL)
152
155
{
153
156
goto_programt::targett assertion = rest_program.add (
154
157
goto_programt::make_assertion (exit_cond, loop_head->source_location ()));
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ class goto_unwindt
26
26
CONTINUE,
27
27
PARTIAL,
28
28
ASSERT_ASSUME,
29
+ ASSERT_PARTIAL,
29
30
ASSUME
30
31
};
31
32
Original file line number Diff line number Diff line change @@ -245,15 +245,10 @@ void goto_symext::symex_function_call_post_clean(
245
245
// see if it's too much
246
246
if (stop_recursing)
247
247
{
248
- if (symex_config.partial_loops )
248
+ if (symex_config.unwinding_assertions )
249
+ vcc (false_exprt (), " recursion unwinding assertion" , state);
250
+ if (!symex_config.partial_loops )
249
251
{
250
- // it's ok, ignore
251
- }
252
- else
253
- {
254
- if (symex_config.unwinding_assertions )
255
- vcc (false_exprt (), " recursion unwinding assertion" , state);
256
-
257
252
// Rule out this path:
258
253
symex_assume_l2 (state, false_exprt ());
259
254
}
Original file line number Diff line number Diff line change @@ -932,25 +932,19 @@ void goto_symext::loop_bound_exceeded(
932
932
else
933
933
negated_cond=not_exprt (guard);
934
934
935
- if (! symex_config.partial_loops )
935
+ if (symex_config.unwinding_assertions )
936
936
{
937
- if (symex_config.unwinding_assertions )
938
- {
939
- // Generate VCC for unwinding assertion.
940
- vcc (
941
- negated_cond,
942
- " unwinding assertion loop " + std::to_string (loop_number),
943
- state);
944
- }
937
+ // Generate VCC for unwinding assertion.
938
+ vcc (
939
+ negated_cond,
940
+ " unwinding assertion loop " + std::to_string (loop_number),
941
+ state);
942
+ }
945
943
944
+ if (!symex_config.partial_loops )
945
+ {
946
946
// generate unwinding assumption, unless we permit partial loops
947
947
symex_assume_l2 (state, negated_cond);
948
-
949
- if (symex_config.unwinding_assertions )
950
- {
951
- // add to state guard to prevent further assignments
952
- state.guard .add (negated_cond);
953
- }
954
948
}
955
949
}
956
950
You can’t perform that action at this time.
0 commit comments