Skip to content

Commit 40bd81a

Browse files
peterschrammeltautschnig
authored andcommitted
Split array-list into assignments and hide dynamic objects
1 parent f181ee2 commit 40bd81a

File tree

1 file changed

+53
-12
lines changed

1 file changed

+53
-12
lines changed

src/goto-programs/graphml_witness.cpp

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,29 @@ std::string graphml_witnesst::convert_assign_rec(
6565

6666
std::string result;
6767

68-
if(assign.rhs().id()==ID_array)
68+
if(assign.rhs().id()=="array-list")
69+
{
70+
const array_typet &type=
71+
to_array_type(ns.follow(assign.rhs().type()));
72+
73+
const auto ops=assign.rhs().operands();
74+
DATA_INVARIANT(
75+
ops.size()%2==0,
76+
"array-list has odd number of operands");
77+
78+
for(size_t listidx=0; listidx!=ops.size(); listidx+=2)
79+
{
80+
index_exprt index(
81+
assign.lhs(),
82+
ops[listidx],
83+
type.subtype());
84+
if(!result.empty())
85+
result+=' ';
86+
result+=
87+
convert_assign_rec(identifier, code_assignt(index, ops[listidx+1]));
88+
}
89+
}
90+
else if(assign.rhs().id()==ID_array)
6991
{
7092
const array_typet &type=
7193
to_array_type(ns.follow(assign.rhs().type()));
@@ -148,7 +170,6 @@ std::string graphml_witnesst::convert_assign_rec(
148170

149171
result=lhs+" = "+from_expr(ns, identifier, clean_rhs)+";";
150172
}
151-
152173
cache.insert({{identifier.get_no(), &assign.read()}, result});
153174
return result;
154175
}
@@ -188,6 +209,21 @@ static bool filter_out(
188209
return false;
189210
}
190211

212+
static bool contains_symbol_prefix(const exprt &expr, const std::string &prefix){
213+
if(expr.id()==ID_symbol &&
214+
has_prefix(id2string(to_symbol_expr(expr).get_identifier()), prefix))
215+
{
216+
return true;
217+
}
218+
219+
forall_operands(it, expr)
220+
{
221+
if(contains_symbol_prefix(*it, prefix))
222+
return true;
223+
}
224+
return false;
225+
}
226+
191227
/// counterexample witness
192228
void graphml_witnesst::operator()(const goto_tracet &goto_trace)
193229
{
@@ -308,16 +344,21 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
308344
data_t.set_attribute("key", "createThread");
309345
data_t.data=std::to_string(++thread_id);
310346
}
311-
else if(id2string(it->lhs_object.get_identifier())
312-
.find("#return_value")==std::string::npos &&
313-
id2string(it->lhs_object.get_identifier())
314-
.find("thread")==std::string::npos &&
315-
id2string(it->lhs_object.get_identifier())
316-
.find("mutex")==std::string::npos &&
317-
(!it->lhs_object_value.is_constant() ||
318-
!it->lhs_object_value.has_operands() ||
319-
!has_prefix(id2string(it->lhs_object_value.op0().get(ID_value)),
320-
"INVALID-")))
347+
else if(
348+
id2string(it->lhs_object.get_identifier())
349+
.find("#return_value")==std::string::npos &&
350+
!contains_symbol_prefix(
351+
it->lhs_object_value, "symex_dynamic::dynamic_object") &&
352+
!contains_symbol_prefix(
353+
it->lhs_object, "symex_dynamic::dynamic_object") &&
354+
id2string(it->lhs_object.get_identifier())
355+
.find("thread")==std::string::npos &&
356+
id2string(it->lhs_object.get_identifier())
357+
.find("mutex")==std::string::npos &&
358+
(!it->lhs_object_value.is_constant() ||
359+
!it->lhs_object_value.has_operands() ||
360+
!has_prefix(id2string(it->lhs_object_value.op0().get(ID_value)),
361+
"INVALID-")))
321362
{
322363
xmlt &val=edge.new_element("data");
323364
val.set_attribute("key", "assumption");

0 commit comments

Comments
 (0)