Skip to content

Commit 59a738e

Browse files
committed
goto-symex: print status note and conditional warning for self-loops
Unless CBMC is invoked with --no-self-loops-to-assumptions, self-loops are replaced by assumptions. This commit now introduces a status output that such replacement is happening, and also a warning when --unwinding-assertions is set: as the loop is replaced by an assumption, no unwinding assertions can possible be generated. This behaviour may be unexpected by the user, and we should therefore let them know what is going on. Fixes: #6433
1 parent 380179b commit 59a738e

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

regression/cbmc/self_loops_to_assumptions1/default.desc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
CORE
22
main.c
33
--unwind 1 --unwinding-assertions
4+
^replacing self-loop at file main.c line 3 function main by assume\(false\)$
5+
^no unwinding assertion will be generated for self-loop at file main.c line 3 function main$
46
^EXIT=0$
57
^SIGNAL=0$
68
^VERIFICATION SUCCESSFUL$

regression/cbmc/self_loops_to_assumptions1/no-assume.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ main.c
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
77
--
8+
^replacing self-loop

src/goto-symex/symex_goto.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]
1616

1717
#include <util/exception_utils.h>
1818
#include <util/expr_util.h>
19+
#include <util/format_expr.h>
1920
#include <util/invariant.h>
2021
#include <util/pointer_expr.h>
2122
#include <util/pointer_offset_size.h>
@@ -279,10 +280,18 @@ void goto_symext::symex_goto(statet &state)
279280
{
280281
// generate assume(false) or a suitable negation if this
281282
// instruction is a conditional goto
282-
if(new_guard.is_true())
283-
symex_assume_l2(state, false_exprt());
284-
else
285-
symex_assume_l2(state, not_exprt(new_guard));
283+
exprt negated_guard = not_exprt{new_guard};
284+
do_simplify(negated_guard);
285+
log.statistics() << "replacing self-loop at "
286+
<< state.source.pc->source_location() << " by assume("
287+
<< format(negated_guard) << ")" << messaget::eom;
288+
if(symex_config.unwinding_assertions)
289+
{
290+
log.warning()
291+
<< "no unwinding assertion will be generated for self-loop at "
292+
<< state.source.pc->source_location() << messaget::eom;
293+
}
294+
symex_assume_l2(state, negated_guard);
286295

287296
// next instruction
288297
symex_transition(state);

0 commit comments

Comments
 (0)