Skip to content

Commit 0aff1c5

Browse files
peterschrammeltautschnig
authored andcommitted
GraphML output: hide assignments to dynamic objects
These symbols do not occur in the input program.
1 parent d0da778 commit 0aff1c5

File tree

1 file changed

+48
-20
lines changed

1 file changed

+48
-20
lines changed

src/goto-programs/graphml_witness.cpp

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening
1515
#include <util/byte_operators.h>
1616
#include <util/c_types.h>
1717
#include <util/cprover_prefix.h>
18+
#include <util/pointer_predicates.h>
1819
#include <util/prefix.h>
1920
#include <util/ssa_expr.h>
2021

@@ -216,6 +217,23 @@ static bool filter_out(
216217
return false;
217218
}
218219

220+
static bool contains_symbol_prefix(const exprt &expr, const std::string &prefix)
221+
{
222+
if(
223+
expr.id() == ID_symbol &&
224+
has_prefix(id2string(to_symbol_expr(expr).get_identifier()), prefix))
225+
{
226+
return true;
227+
}
228+
229+
forall_operands(it, expr)
230+
{
231+
if(contains_symbol_prefix(*it, prefix))
232+
return true;
233+
}
234+
return false;
235+
}
236+
219237
/// counterexample witness
220238
void graphml_witnesst::operator()(const goto_tracet &goto_trace)
221239
{
@@ -322,28 +340,38 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
322340
data_l.data=id2string(graphml[from].line);
323341
}
324342

325-
if(it->type==goto_trace_stept::typet::ASSIGNMENT &&
326-
it->full_lhs_value.is_not_nil() &&
327-
it->full_lhs.is_not_nil())
343+
const auto lhs_object = it->get_lhs_object();
344+
if(
345+
it->type == goto_trace_stept::typet::ASSIGNMENT &&
346+
lhs_object.has_value())
328347
{
329-
xmlt &val=edge.new_element("data");
330-
val.set_attribute("key", "assumption");
331-
332-
code_assignt assign{it->full_lhs, it->full_lhs_value};
333-
irep_idt identifier = irep_idt();
334-
if(const auto object = it->get_lhs_object())
335-
identifier = object->get_identifier();
336-
val.data = convert_assign_rec(identifier, assign);
337-
338-
xmlt &val_s=edge.new_element("data");
339-
val_s.set_attribute("key", "assumption.scope");
340-
val_s.data = id2string(it->function_id);
341-
342-
if(has_prefix(val.data, "\\result ="))
348+
const std::string &lhs_id = id2string(lhs_object->get_identifier());
349+
if(
350+
!contains_symbol_prefix(
351+
it->full_lhs_value, SYMEX_DYNAMIC_PREFIX "dynamic_object") &&
352+
!contains_symbol_prefix(
353+
it->full_lhs, SYMEX_DYNAMIC_PREFIX "dynamic_object") &&
354+
(!it->full_lhs_value.is_constant() ||
355+
!it->full_lhs_value.has_operands() ||
356+
!has_prefix(
357+
id2string(it->full_lhs_value.op0().get(ID_value)), "INVALID-")))
343358
{
344-
xmlt &val_f = edge.new_element("data");
345-
val_f.set_attribute("key", "assumption.resultfunction");
346-
val_f.data = id2string(it->function_id);
359+
xmlt &val = edge.new_element("data");
360+
val.set_attribute("key", "assumption");
361+
362+
code_assignt assign{it->full_lhs, it->full_lhs_value};
363+
val.data = convert_assign_rec(lhs_id, assign);
364+
365+
xmlt &val_s = edge.new_element("data");
366+
val_s.set_attribute("key", "assumption.scope");
367+
val_s.data = id2string(it->function_id);
368+
369+
if(has_prefix(val.data, "\\result ="))
370+
{
371+
xmlt &val_f = edge.new_element("data");
372+
val_f.set_attribute("key", "assumption.resultfunction");
373+
val_f.data = id2string(it->function_id);
374+
}
347375
}
348376
}
349377
else if(it->type==goto_trace_stept::typet::GOTO &&

0 commit comments

Comments
 (0)