Skip to content

Commit e7d28c4

Browse files
lucasccordeirotautschnig
authored andcommitted
set internal for specific variables in the counterexample trace for test-gen-support
set internal for variable assignments related to dynamic_object[0-9], dynamic_[0-9]_array, _start function-return step, and CPROVER internal functions (e.g., __CPROVER_initialize). This PR fixes diffblue/test-gen#20.
1 parent b49820b commit e7d28c4

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/goto-symex/build_goto_trace.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,63 @@ exprt adjust_lhs_object(
109109
return nil_exprt();
110110
}
111111

112+
/// set internal field for variable assignment related to dynamic_object[0-9]
113+
/// and dynamic_[0-9]_array.
114+
void hide_dynamic_object(
115+
const exprt &expr,
116+
goto_trace_stept &goto_trace_step,
117+
const namespacet &ns)
118+
{
119+
if(expr.id()==ID_symbol)
120+
{
121+
const irep_idt &id=to_ssa_expr(expr).get_original_name();
122+
const symbolt *symbol;
123+
if(!ns.lookup(id, symbol))
124+
{
125+
bool result=symbol->type.get_bool("#dynamic");
126+
if(result)
127+
goto_trace_step.hidden=true;
128+
}
129+
}
130+
else
131+
{
132+
forall_operands(it, expr)
133+
hide_dynamic_object(*it, goto_trace_step, ns);
134+
}
135+
}
136+
137+
/// set internal for variables assignments related to dynamic_object and CPROVER
138+
/// internal functions (e.g., __CPROVER_initialize)
139+
void update_fields_to_hidden(
140+
const symex_target_equationt::SSA_stept &SSA_step,
141+
goto_trace_stept &goto_trace_step,
142+
const namespacet &ns)
143+
{
144+
// hide dynamic_object in both lhs and rhs expressions
145+
hide_dynamic_object(SSA_step.ssa_lhs, goto_trace_step, ns);
146+
hide_dynamic_object(SSA_step.ssa_rhs, goto_trace_step, ns);
147+
148+
// hide internal CPROVER functions (e.g., __CPROVER_initialize)
149+
if(SSA_step.is_function_call())
150+
{
151+
if(SSA_step.source.pc->source_location.as_string().empty())
152+
goto_trace_step.hidden=true;
153+
}
154+
155+
// set internal field to input and output steps
156+
if(goto_trace_step.type==goto_trace_stept::typet::OUTPUT ||
157+
goto_trace_step.type==goto_trace_stept::typet::INPUT)
158+
{
159+
goto_trace_step.hidden=true;
160+
}
161+
162+
// set internal field to _start function-return step
163+
if(SSA_step.source.pc->function==goto_functionst::entry_point())
164+
{
165+
goto_trace_step.internal=true;
166+
}
167+
}
168+
112169
void build_goto_trace(
113170
const symex_target_equationt &target,
114171
symex_target_equationt::SSA_stepst::const_iterator end_step,
@@ -216,6 +273,9 @@ void build_goto_trace(
216273
goto_trace_step.formatted=SSA_step.formatted;
217274
goto_trace_step.identifier=SSA_step.identifier;
218275

276+
// hide specific variables in the counterexample trace
277+
update_fields_to_hidden(SSA_step, goto_trace_step, ns);
278+
219279
goto_trace_step.assignment_type=
220280
(it->is_assignment()&&
221281
(SSA_step.assignment_type==

0 commit comments

Comments
 (0)