Skip to content

Commit ba964e7

Browse files
marek-trtikDaniel Kroening
authored and
Daniel Kroening
committed
GraphML: Use the \result symbol in place of return value symbols
The witness specification permits use of \result in assumptions (in violation witnesses), but then also requires setting assumption.resultfunction.
1 parent ad036c3 commit ba964e7

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/goto-programs/graphml_witness.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,14 @@ std::string graphml_witnesst::convert_assign_rec(
144144
exprt clean_lhs = assign.lhs();
145145
remove_l0_l1(clean_lhs);
146146
std::string lhs = expr_to_string(ns, identifier, clean_lhs);
147-
if(lhs.find('$')!=std::string::npos)
147+
148+
if(
149+
lhs.find("#return_value") != std::string::npos ||
150+
(lhs.find('$') != std::string::npos &&
151+
has_prefix(lhs, "return_value___VERIFIER_nondet_")))
152+
{
148153
lhs="\\result";
154+
}
149155

150156
result = lhs + " = " + expr_to_string(ns, identifier, clean_rhs) + ";";
151157
}
@@ -300,13 +306,23 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
300306
{
301307
xmlt &val=edge.new_element("data");
302308
val.set_attribute("key", "assumption");
303-
val.data = expr_to_string(ns, it->function_id, it->full_lhs) + " = " +
304-
expr_to_string(ns, it->function_id, it->full_lhs_value) +
305-
";";
309+
310+
code_assignt assign{it->full_lhs, it->full_lhs_value};
311+
irep_idt identifier = irep_idt();
312+
if(const auto object = it->get_lhs_object())
313+
identifier = object->get_identifier();
314+
val.data = convert_assign_rec(identifier, assign);
306315

307316
xmlt &val_s=edge.new_element("data");
308317
val_s.set_attribute("key", "assumption.scope");
309318
val_s.data = id2string(it->function_id);
319+
320+
if(has_prefix(val.data, "\\result ="))
321+
{
322+
xmlt &val_f = edge.new_element("data");
323+
val_f.set_attribute("key", "assumption.resultfunction");
324+
val_f.data = id2string(it->function_id);
325+
}
310326
}
311327
else if(it->type==goto_trace_stept::typet::GOTO &&
312328
it->pc->is_goto())

0 commit comments

Comments
 (0)