Skip to content

Commit 755c025

Browse files
committed
Simplify lhs before passing to symex_assign
This can help avoid some uses of byte_update, as the regression test shows.
1 parent 8412eb0 commit 755c025

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/goto-symex/symex_assign.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <util/byte_operators.h>
1515
#include <util/cprover_prefix.h>
16-
16+
#include <util/expr_util.h>
17+
#include <util/invariant.h>
1718
#include <util/c_types.h>
1819

1920
#include "goto_symex_state.h"
@@ -28,6 +29,19 @@ void goto_symext::symex_assign(
2829
exprt rhs=code.rhs();
2930

3031
clean_expr(lhs, state, true);
32+
// make the structure of the lhs as simple as possible to avoid,
33+
// e.g., (b ? s1 : s2).member=X resulting in
34+
// (b ? s1 : s2)=(b ? s1 : s2) with member:=X and then
35+
// s1=b ? ((b ? s1 : s2) with member:=X) : s1
36+
// when all we need is
37+
// s1=s1 with member:=X [and guard b]
38+
// s2=s2 with member:=X [and guard !b]
39+
do_simplify(lhs);
40+
// make sure simplify has not re-introduced any dereferencing that
41+
// had previously been cleaned away
42+
INVARIANT(
43+
!has_subexpr(lhs, ID_dereference),
44+
"simplify re-introduced dereferencing");
3145
clean_expr(rhs, state, false);
3246

3347
if(rhs.id()==ID_side_effect)

0 commit comments

Comments
 (0)