Skip to content

Commit a5f7739

Browse files
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 c337363 commit a5f7739

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

src/goto-symex/build_goto_trace.cpp

+82
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,85 @@ exprt adjust_lhs_object(
132132

133133
/*******************************************************************\
134134
135+
Function: hide_dynamic_object
136+
137+
Inputs:
138+
139+
Outputs:
140+
141+
Purpose: hide variable assignments related to dynamic_object[0-9]
142+
and dynamic_[0-9]_array.
143+
144+
\*******************************************************************/
145+
146+
void hide_dynamic_object(
147+
const exprt &expr,
148+
goto_trace_stept &goto_trace_step,
149+
const namespacet &ns)
150+
{
151+
if(expr.id()==ID_symbol)
152+
{
153+
const irep_idt &id=to_ssa_expr(expr).get_original_name();
154+
const symbolt *symbol;
155+
if(!ns.lookup(id, symbol))
156+
{
157+
bool result=symbol->type.get_bool("#dynamic");
158+
if(result)
159+
goto_trace_step.hidden=true;
160+
}
161+
}
162+
else
163+
{
164+
forall_operands(it, expr)
165+
hide_dynamic_object(*it, goto_trace_step, ns);
166+
}
167+
}
168+
169+
/*******************************************************************\
170+
171+
Function: update_fields_to_hidden
172+
173+
Inputs:
174+
175+
Outputs:
176+
177+
Purpose: hide variables assignments related to dynamic_object
178+
and CPROVER internal functions (e.g., __CPROVER_initialize)
179+
180+
\*******************************************************************/
181+
182+
void update_fields_to_hidden(
183+
const symex_target_equationt::SSA_stept &SSA_step,
184+
goto_trace_stept &goto_trace_step,
185+
const namespacet &ns)
186+
{
187+
// hide dynamic_object in both lhs and rhs expressions
188+
hide_dynamic_object(SSA_step.ssa_lhs, goto_trace_step, ns);
189+
hide_dynamic_object(SSA_step.ssa_rhs, goto_trace_step, ns);
190+
191+
// hide internal CPROVER functions (e.g., __CPROVER_initialize)
192+
if(SSA_step.is_function_call())
193+
{
194+
if(SSA_step.source.pc->source_location.as_string().empty())
195+
goto_trace_step.hidden=true;
196+
}
197+
198+
// hide input and output steps
199+
if(goto_trace_step.type==goto_trace_stept::OUTPUT ||
200+
goto_trace_step.type==goto_trace_stept::INPUT)
201+
{
202+
goto_trace_step.hidden=true;
203+
}
204+
205+
// set internal field to _start function-return step
206+
if(SSA_step.source.pc->function==goto_functionst::entry_point())
207+
{
208+
goto_trace_step.internal=true;
209+
}
210+
}
211+
212+
/*******************************************************************\
213+
135214
Function: build_goto_trace
136215
137216
Inputs:
@@ -237,6 +316,9 @@ void build_goto_trace(
237316
goto_trace_step.formatted=SSA_step.formatted;
238317
goto_trace_step.identifier=SSA_step.identifier;
239318

319+
// hide specific variables in the counterexample trace
320+
update_fields_to_hidden(SSA_step, goto_trace_step, ns);
321+
240322
goto_trace_step.assignment_type=
241323
(it->is_assignment()&&
242324
(SSA_step.assignment_type==symex_targett::VISIBLE_ACTUAL_PARAMETER ||

0 commit comments

Comments
 (0)