Skip to content

Simplify lhs before passing to symex_assign #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/goto-symex/symex_assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Author: Daniel Kroening, [email protected]

#include <util/byte_operators.h>
#include <util/cprover_prefix.h>

#include <util/expr_util.h>
#include <util/invariant.h>
#include <util/c_types.h>

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

clean_expr(lhs, state, true);
// make the structure of the lhs as simple as possible to avoid,
// e.g., (b ? s1 : s2).member=X resulting in
// (b ? s1 : s2)=(b ? s1 : s2) with member:=X and then
// s1=b ? ((b ? s1 : s2) with member:=X) : s1
// when all we need is
// s1=s1 with member:=X [and guard b]
// s2=s2 with member:=X [and guard !b]
do_simplify(lhs);
// make sure simplify has not re-introduced any dereferencing that
// had previously been cleaned away
INVARIANT(
!has_subexpr(lhs, ID_dereference),
"simplify re-introduced dereferencing");
clean_expr(rhs, state, false);

if(rhs.id()==ID_side_effect)
Expand Down