Skip to content

Commit d6dfd87

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
GraphML witnesses: unwind "with" expressions
Witness validators cannot be expected to understand CBMC's "with" expressions. Fixes: #4486
1 parent 8a7eb32 commit d6dfd87

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/goto-programs/graphml_witness.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,31 @@ std::string graphml_witnesst::convert_assign_rec(
152152
break;
153153
}
154154
}
155+
else if(assign.rhs().id() == ID_with)
156+
{
157+
const with_exprt &with_expr = to_with_expr(assign.rhs());
158+
const auto &ops = with_expr.operands();
159+
160+
for(std::size_t i = 1; i < ops.size(); i += 2)
161+
{
162+
if(!result.empty())
163+
result += ' ';
164+
165+
if(ops[i].id() == ID_member_name)
166+
{
167+
const member_exprt member{
168+
assign.lhs(), ops[i].get(ID_component_name), ops[i + 1].type()};
169+
result +=
170+
convert_assign_rec(identifier, code_assignt(member, ops[i + 1]));
171+
}
172+
else
173+
{
174+
const index_exprt index{assign.lhs(), ops[i]};
175+
result +=
176+
convert_assign_rec(identifier, code_assignt(index, ops[i + 1]));
177+
}
178+
}
179+
}
155180
else
156181
{
157182
exprt clean_rhs=assign.rhs();
@@ -527,7 +552,7 @@ void graphml_witnesst::operator()(const symex_target_equationt &equation)
527552
irep_idt identifier=it->ssa_lhs.get_object_name();
528553

529554
graphml[to].has_invariant=true;
530-
code_assignt assign(it->ssa_full_lhs, it->ssa_rhs);
555+
code_assignt assign(it->ssa_lhs, it->ssa_rhs);
531556
graphml[to].invariant=convert_assign_rec(identifier, assign);
532557
graphml[to].invariant_scope = id2string(it->source.function_id);
533558
}

0 commit comments

Comments
 (0)