Skip to content

Commit 9c48c53

Browse files
Get property ID for SSA step assert
Make reusable to avoid error-prone duplication.
1 parent 73ebbb4 commit 9c48c53

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

src/cbmc/all_properties.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,16 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
7878
{
7979
if(it->is_assert())
8080
{
81-
irep_idt property_id;
81+
irep_idt property_id = it->get_property_id();
8282

83-
if(it->source.pc->is_assert())
84-
property_id=it->source.pc->source_location.get_property_id();
85-
else if(it->source.pc->is_goto())
83+
if(property_id.empty())
84+
continue;
85+
86+
if(it->source.pc->is_goto())
8687
{
87-
// this is likely an unwinding assertion
88-
property_id=id2string(
89-
it->source.pc->source_location.get_function())+".unwind."+
90-
std::to_string(it->source.pc->loop_number);
91-
goal_map[property_id].description=it->comment;
88+
// goto may yield an unwinding assertion
89+
goal_map[property_id].description = it->comment;
9290
}
93-
else
94-
continue;
9591

9692
goal_map[property_id].instances.push_back(it);
9793
}

src/goto-symex/symex_target_equation.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,3 +1003,27 @@ void symex_target_equationt::SSA_stept::validate(
10031003
break;
10041004
}
10051005
}
1006+
1007+
irep_idt symex_target_equationt::SSA_stept::get_property_id() const
1008+
{
1009+
PRECONDITION(is_assert());
1010+
1011+
irep_idt property_id;
1012+
1013+
if(source.pc->is_assert())
1014+
{
1015+
property_id = source.pc->source_location.get_property_id();
1016+
}
1017+
else if(source.pc->is_goto())
1018+
{
1019+
// this is likely an unwinding assertion
1020+
property_id = id2string(source.pc->source_location.get_function()) +
1021+
".unwind." + std::to_string(source.pc->loop_number);
1022+
}
1023+
else
1024+
{
1025+
// return empty
1026+
}
1027+
1028+
return property_id;
1029+
}

src/goto-symex/symex_target_equation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ class symex_target_equationt:public symex_targett
279279
// NOLINTNEXTLINE(whitespace/line_length)
280280
bool is_atomic_end() const { return type==goto_trace_stept::typet::ATOMIC_END; }
281281

282+
// return the property ID if this is an assertion step
283+
irep_idt get_property_id() const;
284+
282285
// we may choose to hide
283286
bool hidden=false;
284287

0 commit comments

Comments
 (0)