Skip to content

Commit 4a24bd9

Browse files
author
Daniel Kroening
authored
Merge pull request #734 from tautschnig/sv-comp-support
SV-COMP support patches (from #363)
2 parents 7ddee5f + df0890b commit 4a24bd9

File tree

2 files changed

+78
-28
lines changed

2 files changed

+78
-28
lines changed

src/goto-programs/builtin_functions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,13 @@ void goto_convertt::do_function_call_symbol(
12451245
error() << identifier << " expected not to have LHS" << eom;
12461246
throw 0;
12471247
}
1248+
1249+
// __VERIFIER_error has abort() semantics, even if no assertions
1250+
// are being checked
1251+
goto_programt::targett a=dest.add_instruction(ASSUME);
1252+
a->guard=false_exprt();
1253+
a->source_location=function.source_location();
1254+
a->source_location.set("user-provided", true);
12481255
}
12491256
else if(has_prefix(
12501257
id2string(identifier), "java::java.lang.AssertionError.<init>:"))

src/goto-programs/graphml_witness.cpp

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,65 @@ std::string graphml_witnesst::convert_assign_rec(
146146
exprt clean_rhs=assign.rhs();
147147
remove_l0_l1(clean_rhs);
148148

149-
result=from_expr(ns, identifier, assign.lhs())+" = "+
150-
from_expr(ns, identifier, clean_rhs)+";";
149+
std::string lhs=from_expr(ns, identifier, assign.lhs());
150+
if(lhs.find('$')!=std::string::npos)
151+
lhs="\\result";
152+
153+
result=lhs+" = "+from_expr(ns, identifier, clean_rhs)+";";
151154
}
152155

153156
return result;
154157
}
155158

156159
/*******************************************************************\
157160
161+
Function: filter_out
162+
163+
Inputs:
164+
165+
Outputs:
166+
167+
Purpose:
168+
169+
\*******************************************************************/
170+
171+
static bool filter_out(
172+
const goto_tracet &goto_trace,
173+
const goto_tracet::stepst::const_iterator &prev_it,
174+
goto_tracet::stepst::const_iterator &it)
175+
{
176+
if(it->hidden &&
177+
(!it->is_assignment() ||
178+
to_code_assign(it->pc->code).rhs().id()!=ID_side_effect ||
179+
to_code_assign(it->pc->code).rhs().get(ID_statement)!=ID_nondet))
180+
return true;
181+
182+
if(!it->is_assignment() && !it->is_goto() && !it->is_assert())
183+
return true;
184+
185+
// we filter out steps with the same source location
186+
// TODO: if these are assignments we should accumulate them into
187+
// a single edge
188+
if(prev_it!=goto_trace.steps.end() &&
189+
prev_it->pc->source_location==it->pc->source_location)
190+
return true;
191+
192+
if(it->is_goto() && it->pc->guard.is_true())
193+
return true;
194+
195+
const source_locationt &source_location=it->pc->source_location;
196+
197+
if(source_location.is_nil() ||
198+
source_location.get_file().empty() ||
199+
source_location.is_built_in() ||
200+
source_location.get_line().empty())
201+
return true;
202+
203+
return false;
204+
}
205+
206+
/*******************************************************************\
207+
158208
Function: graphml_witnesst::operator()
159209
160210
Inputs:
@@ -184,20 +234,7 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
184234
it!=goto_trace.steps.end();
185235
it++) // we cannot replace this by a ranged for
186236
{
187-
const source_locationt &source_location=it->pc->source_location;
188-
189-
if(it->hidden ||
190-
(!it->is_assignment() && !it->is_goto() && !it->is_assert()) ||
191-
// we filter out steps with the same source location
192-
// TODO: if these are assignments we should accumulate them into
193-
// a single edge
194-
(prev_it!=goto_trace.steps.end() &&
195-
prev_it->pc->source_location==it->pc->source_location) ||
196-
(it->is_goto() && it->pc->guard.is_true()) ||
197-
source_location.is_nil() ||
198-
source_location.get_file().empty() ||
199-
source_location.is_built_in() ||
200-
source_location.get_line().empty())
237+
if(filter_out(goto_trace, prev_it, it))
201238
{
202239
step_to_node[it->step_nr]=sink;
203240

@@ -219,6 +256,8 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
219256

220257
prev_it=it;
221258

259+
const source_locationt &source_location=it->pc->source_location;
260+
222261
const graphmlt::node_indext node=graphml.add_node();
223262
graphml[node].node_name=
224263
std::to_string(it->pc->location_number)+"."+std::to_string(it->step_nr);
@@ -278,21 +317,25 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
278317
data_l.data=id2string(graphml[from].line);
279318
}
280319

281-
if((it->type==goto_trace_stept::ASSIGNMENT ||
282-
it->type==goto_trace_stept::DECL) &&
320+
if(it->type==goto_trace_stept::ASSIGNMENT &&
283321
it->lhs_object_value.is_not_nil() &&
284322
it->full_lhs.is_not_nil())
285323
{
286-
irep_idt identifier=it->lhs_object.get_identifier();
287-
288-
xmlt &val=edge.new_element("data");
289-
val.set_attribute("key", "assumption");
290-
code_assignt assign(it->lhs_object, it->lhs_object_value);
291-
val.data=convert_assign_rec(identifier, assign);
292-
293-
xmlt &val_s=edge.new_element("data");
294-
val_s.set_attribute("key", "assumption.scope");
295-
val_s.data=id2string(it->pc->source_location.get_function());
324+
if(!it->lhs_object_value.is_constant() ||
325+
!it->lhs_object_value.has_operands() ||
326+
!has_prefix(id2string(it->lhs_object_value.op0().get(ID_value)),
327+
"INVALID-"))
328+
{
329+
xmlt &val=edge.new_element("data");
330+
val.set_attribute("key", "assumption");
331+
code_assignt assign(it->lhs_object, it->lhs_object_value);
332+
irep_idt identifier=it->lhs_object.get_identifier();
333+
val.data=convert_assign_rec(identifier, assign);
334+
335+
xmlt &val_s=edge.new_element("data");
336+
val_s.set_attribute("key", "assumption.scope");
337+
val_s.data=id2string(it->pc->source_location.get_function());
338+
}
296339
}
297340
else if(it->type==goto_trace_stept::GOTO &&
298341
it->pc->is_goto())

0 commit comments

Comments
 (0)