Skip to content

Commit c958e2a

Browse files
committed
GraphML witnesses: correctly set the scope of parameters
We would previously use the name of the calling function. Instead, parameter assignments require a special case. Regression test kindly provided by @JanSvejda. Fixes: #4418
1 parent ca263b5 commit c958e2a

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

regression/cbmc/graphml_witness1/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ main.c
4343
<edge source="[0-9\.]*" target="[0-9\.]*">
4444
<data key="originfile">main.c</data>
4545
<data key="startline">29</data>
46-
<data key="assumption.scope">main</data>
46+
<data key="assumption.scope">remove_one</data>
4747
</edge>
4848
<node id="[0-9\.]*"/>
4949
<edge source="[0-9\.]*" target="[0-9\.]*">
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
extern void __VERIFIER_error();
2+
3+
static float one(float *foo)
4+
{
5+
return *foo;
6+
}
7+
8+
static float two(float *foo)
9+
{
10+
return *foo;
11+
}
12+
13+
float x = 0;
14+
15+
void step()
16+
{
17+
x = one(0);
18+
}
19+
20+
int main(void)
21+
{
22+
while(1)
23+
{
24+
step();
25+
if(x == 0)
26+
{
27+
__VERIFIER_error();
28+
}
29+
}
30+
return 0;
31+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--graphml-witness - --unwindset main.0:1 --unwinding-assertions
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
<data key="assumption">foo = \(\(float \*\)0\);</data>
8+
<data key="assumption.scope">one</data>
9+
--
10+
^warning: ignoring

src/goto-programs/graphml_witness.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,13 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
482482

483483
xmlt &val_s = edge.new_element("data");
484484
val_s.set_attribute("key", "assumption.scope");
485-
val_s.data = id2string(it->function_id);
485+
irep_idt function_id = it->function_id;
486+
const symbolt *symbol_ptr = nullptr;
487+
if(!ns.lookup(lhs_id, symbol_ptr) && symbol_ptr->is_parameter)
488+
{
489+
function_id = lhs_id.substr(0, lhs_id.find("::"));
490+
}
491+
val_s.data = id2string(function_id);
486492

487493
if(has_prefix(val.data, "\\result ="))
488494
{

0 commit comments

Comments
 (0)