Skip to content

Commit 5bab915

Browse files
Replace nondet values in trace types
All nondet symbols should be replaced in the trace, but the case of the size in the type of arrays was not handled.
1 parent eba5c98 commit 5bab915

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/goto-symex/build_goto_trace.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,28 @@ static void update_internal_field(
167167
}
168168
}
169169

170+
/// Replace nondet values that appear in \p type by their values as found by
171+
/// \p solver.
172+
static void replace_nondet_in_type(typet &type, const prop_convt &solver)
173+
{
174+
if(type.id() == ID_array)
175+
{
176+
array_typet &array_type = to_array_type(type);
177+
array_type.size() = solver.get(array_type.size());
178+
}
179+
if(type.has_subtype())
180+
replace_nondet_in_type(type.subtype(), solver);
181+
}
182+
183+
/// Replace nondet values that appear in the type of \p expr and its
184+
/// subexpressions type by their values as found by \p solver.
185+
static void replace_nondet_in_type(exprt &expr, const prop_convt &solver)
186+
{
187+
replace_nondet_in_type(expr.type(), solver);
188+
for(auto &sub : expr.operands())
189+
replace_nondet_in_type(sub, solver);
190+
}
191+
170192
void build_goto_trace(
171193
const symex_target_equationt &target,
172194
ssa_step_predicatet is_last_step_to_keep,
@@ -338,12 +360,14 @@ void build_goto_trace(
338360
{
339361
goto_trace_step.full_lhs = build_full_lhs_rec(
340362
prop_conv, ns, SSA_step.original_full_lhs, SSA_step.ssa_full_lhs);
363+
replace_nondet_in_type(goto_trace_step.full_lhs, prop_conv);
341364
}
342365

343366
if(SSA_step.ssa_full_lhs.is_not_nil())
344367
{
345368
goto_trace_step.full_lhs_value = prop_conv.get(SSA_step.ssa_full_lhs);
346369
simplify(goto_trace_step.full_lhs_value, ns);
370+
replace_nondet_in_type(goto_trace_step.full_lhs_value, prop_conv);
347371
}
348372

349373
for(const auto &j : SSA_step.converted_io_args)

0 commit comments

Comments
 (0)