Skip to content

Commit 09e3f82

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 ec7356b commit 09e3f82

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--bounds-check --32 --program-only
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
byte_update

src/goto-symex/symex_assign.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Author: Daniel Kroening, [email protected]
1414
#include <util/byte_operators.h>
1515
#include <util/c_types.h>
1616
#include <util/cprover_prefix.h>
17+
#include <util/expr_util.h>
18+
#include <util/invariant.h>
1719
#include <util/pointer_offset_size.h>
1820

1921
#include "goto_symex_state.h"
@@ -28,6 +30,19 @@ void goto_symext::symex_assign(
2830
exprt rhs=code.rhs();
2931

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

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

0 commit comments

Comments
 (0)