Skip to content

Commit 9b9b82b

Browse files
committed
Simplify lhs before passing to symex_assign
1 parent 4dd5405 commit 9b9b82b

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"
@@ -27,6 +28,19 @@ void goto_symext::symex_assign_rec(
2728
code_assignt deref_code=code;
2829

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

3246
symex_assign(state, deref_code);

0 commit comments

Comments
 (0)