Skip to content

Commit c011ed5

Browse files
Merge pull request #4223 from peterschrammel/get-only-failed-properties
Get_all_property_ids should only return failed properties
2 parents 417e0cc + 94ca5d9 commit c011ed5

File tree

6 files changed

+31
-9
lines changed

6 files changed

+31
-9
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
int main(int argc, char **argv)
2+
{
3+
for(int i = 0; i < 4; i++)
4+
{
5+
char c;
6+
__CPROVER_input("c", c);
7+
if(c == 42)
8+
return 0;
9+
}
10+
return 1;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--xml-ui --cover branch
4+
activate-multi-line-match
5+
EXIT=0
6+
SIGNAL=0
7+
</inputs>\n\s*<goal id="main\.coverage\.1"/>\n\s*<goal id="main\.coverage\.2"/>\n\s*<goal id="main\.coverage\.3"/>\n\s*<goal id="main\.coverage\.5"/>\n\s*</test>
8+
--
9+
^warning: ignoring
10+
--
11+
Expect each goal only occur once per test.

src/cbmc/c_test_input_generator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ json_objectt test_inputst::to_json(
7171
}
7272

7373
json_arrayt goal_refs;
74-
for(const auto &goal_id : goto_trace.get_all_property_ids())
74+
for(const auto &goal_id : goto_trace.get_failed_property_ids())
7575
{
7676
goal_refs.push_back(json_stringt(goal_id));
7777
}
@@ -112,7 +112,7 @@ xmlt test_inputst::to_xml(
112112
}
113113
}
114114

115-
for(const auto &goal_id : goto_trace.get_all_property_ids())
115+
for(const auto &goal_id : goto_trace.get_failed_property_ids())
116116
{
117117
xmlt &xml_goal = xml_result.new_element("goal");
118118
xml_goal.set_attribute("id", id2string(goal_id));

src/goto-checker/goto_trace_storage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const goto_tracet &goto_trace_storaget::insert(goto_tracet &&trace)
3333
const goto_tracet &goto_trace_storaget::insert_all(goto_tracet &&trace)
3434
{
3535
traces.push_back(std::move(trace));
36-
const auto &all_property_ids = traces.back().get_all_property_ids();
36+
const auto &all_property_ids = traces.back().get_failed_property_ids();
3737
DATA_INVARIANT(
3838
!all_property_ids.empty(), "a trace must violate at least one assertion");
3939
for(const auto &property_id : all_property_ids)

src/goto-programs/goto_trace.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,13 @@ void show_goto_trace(
773773

774774
const trace_optionst trace_optionst::default_options = trace_optionst();
775775

776-
std::vector<irep_idt> goto_tracet::get_all_property_ids() const
776+
std::set<irep_idt> goto_tracet::get_failed_property_ids() const
777777
{
778-
std::vector<irep_idt> property_ids;
778+
std::set<irep_idt> property_ids;
779779
for(const auto &step : steps)
780780
{
781-
if(step.is_assert())
782-
property_ids.push_back(step.property_id);
781+
if(step.is_assert() && !step.cond_value)
782+
property_ids.insert(step.property_id);
783783
}
784784
return property_ids;
785785
}

src/goto-programs/goto_trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ class goto_tracet
206206
return steps.back();
207207
}
208208

209-
/// Returns the property IDs of all assertions in the trace
210-
std::vector<irep_idt> get_all_property_ids() const;
209+
/// Returns the property IDs of all failed assertions in the trace
210+
std::set<irep_idt> get_failed_property_ids() const;
211211
};
212212

213213
/// Options for printing the trace using show_goto_trace

0 commit comments

Comments
 (0)