Skip to content

Commit 7adf25c

Browse files
committed
Simplify lhs before passing to symex_assign
1 parent 45ce4d0 commit 7adf25c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/goto-symex/symex_assign.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Author: Daniel Kroening, [email protected]
88

99
#include <util/byte_operators.h>
1010
#include <util/cprover_prefix.h>
11+
#include <util/expr_util.h>
1112

1213
#include <ansi-c/c_types.h>
1314

@@ -35,6 +36,17 @@ void goto_symext::symex_assign_rec(
3536
code_assignt deref_code=code;
3637

3738
clean_expr(deref_code.lhs(), state, true);
39+
// make the structure of the lhs as simple as possible to avoid,
40+
// e.g., (b ? s1 : s2).member=X resulting in
41+
// (b ? s1 : s2)=(b ? s1 : s2) with member:=X and then
42+
// s1=b ? ((b ? s1 : s2) with member:=X) : s1
43+
// when all we need is
44+
// s1=s1 with member:=X [and guard b]
45+
// s2=s2 with member:=X [and guard !b]
46+
do_simplify(deref_code.lhs());
47+
// make sure simplify has not re-introduced any dereferencing that
48+
// had previously been cleaned away
49+
assert(!has_subexpr(deref_code.lhs(), ID_dereference));
3850
clean_expr(deref_code.rhs(), state, false);
3951

4052
symex_assign(state, deref_code);

0 commit comments

Comments
 (0)