Skip to content

Commit d21b20b

Browse files
author
Daniel Kroening
authored
Merge pull request #3241 from diffblue/cbmc-goal-ordering
all-properties now shows results in an ordering
2 parents 8ffb656 + 9104800 commit d21b20b

File tree

3 files changed

+57
-8
lines changed

3 files changed

+57
-8
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
CORE
22
main.c
33
--property main.assertion.1 --property main.assertion.3
4+
activate-multi-line-match
45
^EXIT=10$
56
^SIGNAL=0$
6-
^VERIFICATION FAILED
7-
^.*main.assertion.1.*SUCCESS
8-
^.*main.assertion.3.*FAILURE
7+
^VERIFICATION FAILED$
8+
^main.c function main\n\[main\.assertion\.1\] .* SUCCESS\n\[main\.assertion\.3\] .* FAILURE$
99
--
1010
^warning: ignoring

src/cbmc/all_properties.cpp

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "all_properties_class.h"
1313

14+
#include <algorithm>
1415
#include <chrono>
1516

1617
#include <util/xml.h>
@@ -158,17 +159,63 @@ void bmc_all_propertiest::report(const cover_goalst &cover_goals)
158159
{
159160
result() << "\n** Results:" << eom;
160161

161-
for(const auto &goal_pair : goal_map)
162+
// collect goals in a vector
163+
std::vector<goal_mapt::const_iterator> goals;
164+
165+
for(auto g_it = goal_map.begin(); g_it != goal_map.end(); g_it++)
166+
goals.push_back(g_it);
167+
168+
// now determine an ordering for those goals:
169+
// 1. alphabetical ordering of file name
170+
// 2. numerical ordering of line number
171+
// 3. alphabetical ordering of goal ID
172+
std::sort(
173+
goals.begin(),
174+
goals.end(),
175+
[](goal_mapt::const_iterator git1, goal_mapt::const_iterator git2) {
176+
const auto &g1 = git1->second.source_location;
177+
const auto &g2 = git2->second.source_location;
178+
if(g1.get_file() != g2.get_file())
179+
return id2string(g1.get_file()) < id2string(g2.get_file());
180+
else if(!g1.get_line().empty() && !g2.get_line().empty())
181+
return std::stoul(id2string(g1.get_line())) <
182+
std::stoul(id2string(g2.get_line()));
183+
else
184+
return id2string(git1->first) < id2string(git2->first);
185+
});
186+
187+
// now show in the order we have determined
188+
189+
irep_idt previous_function;
190+
for(const auto &g : goals)
162191
{
163-
result() << "[" << goal_pair.first << "] "
164-
<< goal_pair.second.description << ": ";
192+
const auto &l = g->second.source_location;
165193

166-
if(goal_pair.second.status == goalt::statust::SUCCESS)
194+
if(l.get_function() != previous_function)
195+
{
196+
if(!previous_function.empty())
197+
result() << '\n';
198+
previous_function = l.get_function();
199+
if(!previous_function.empty())
200+
{
201+
if(!l.get_file().empty())
202+
result() << l.get_file() << ' ';
203+
if(!l.get_function().empty())
204+
result() << "function " << l.get_function();
205+
result() << eom;
206+
}
207+
}
208+
209+
result() << faint << '[' << g->first << "] " << reset;
210+
211+
result() << g->second.description << ": ";
212+
213+
if(g->second.status == goalt::statust::SUCCESS)
167214
result() << green;
168215
else
169216
result() << red;
170217

171-
result() << goal_pair.second.status_string() << reset << eom;
218+
result() << g->second.status_string() << reset << eom;
172219
}
173220

174221
if(bmc.options.get_bool_option("trace"))

src/cbmc/all_properties_class.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class bmc_all_propertiest:
4040
instancest;
4141
instancest instances;
4242
std::string description;
43+
source_locationt source_location;
4344

4445
// if failed, we compute a goto_trace for the first failing instance
4546
enum statust { UNKNOWN, FAILURE, SUCCESS, ERROR } status;
@@ -64,6 +65,7 @@ class bmc_all_propertiest:
6465
const goto_programt::instructiont &instruction):
6566
status(statust::UNKNOWN)
6667
{
68+
source_location = instruction.source_location;
6769
description=id2string(instruction.source_location.get_comment());
6870
}
6971

0 commit comments

Comments
 (0)