Skip to content

Commit d2fb690

Browse files
Merge pull request #4964 from hannes-steffenhagen-diffblue/fix/trace-decl-initializers
Symex trace: show implicit value associated with composite declarations
2 parents 9643ec2 + 407c149 commit d2fb690

File tree

6 files changed

+38
-5
lines changed

6 files changed

+38
-5
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <assert.h>
2+
3+
struct SomeStruct
4+
{
5+
int x;
6+
};
7+
8+
int main(void)
9+
{
10+
struct SomeStruct x;
11+
// this should cause
12+
// visible initialization of
13+
// x to value other than 0
14+
// if assertion fails
15+
assert(x.x == 0);
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
test.c
3+
--trace
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
x=\{ \.x=0 \}
9+
^warning: ignoring
10+
--
11+
This tests for the counterexample shown in the trace having sensible values.
12+
In this case, we are asserting that x.x == 0, so x.x should have a value other
13+
than 0 if the assertion fails.

src/goto-symex/symex_decl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
5454
target.decl(
5555
state.guard.as_expr(),
5656
ssa,
57+
state.field_sensitivity.apply(ns, state, ssa, false),
5758
state.source,
58-
hidden?
59-
symex_targett::assignment_typet::HIDDEN:
60-
symex_targett::assignment_typet::STATE);
59+
hidden ? symex_targett::assignment_typet::HIDDEN
60+
: symex_targett::assignment_typet::STATE);
6161

6262
if(path_storage.dirty(ssa.get_object_name()) && state.atomic_section_id == 0)
6363
target.shared_write(

src/goto-symex/symex_target.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,17 @@ class symex_targett
127127
/// Declare a fresh variable. The `cond_expr` is _lhs==lhs_.
128128
/// \param guard: Precondition for a declaration of this variable
129129
/// \param ssa_lhs: Variable to be declared, must be symbol (and not nil)
130+
/// \param initializer: Initial value
130131
/// \param source: Pointer to location in the input GOTO program of this
131132
/// declaration
132133
/// \param assignment_type: To distinguish between different types of
133134
/// assignments (some may be hidden for the further analysis)
134135
virtual void decl(
135136
const exprt &guard,
136137
const ssa_exprt &ssa_lhs,
138+
const exprt &initializer,
137139
const sourcet &source,
138-
assignment_typet assignment_type)=0;
140+
assignment_typet assignment_type) = 0;
139141

140142
/// Remove a variable from the scope.
141143
/// \param guard: Precondition for removal of this variable

src/goto-symex/symex_target_equation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ void symex_target_equationt::assignment(
128128
void symex_target_equationt::decl(
129129
const exprt &guard,
130130
const ssa_exprt &ssa_lhs,
131+
const exprt &initializer,
131132
const sourcet &source,
132133
assignment_typet assignment_type)
133134
{
@@ -138,7 +139,7 @@ void symex_target_equationt::decl(
138139

139140
SSA_step.guard=guard;
140141
SSA_step.ssa_lhs=ssa_lhs;
141-
SSA_step.ssa_full_lhs=ssa_lhs;
142+
SSA_step.ssa_full_lhs = initializer;
142143
SSA_step.original_full_lhs=ssa_lhs.get_original_expr();
143144
SSA_step.hidden=(assignment_type!=assignment_typet::STATE);
144145

src/goto-symex/symex_target_equation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class symex_target_equationt:public symex_targett
7373
virtual void decl(
7474
const exprt &guard,
7575
const ssa_exprt &ssa_lhs,
76+
const exprt &initializer,
7677
const sourcet &source,
7778
assignment_typet assignment_type);
7879

0 commit comments

Comments
 (0)