Skip to content

Commit c94d0af

Browse files
Clang-format
1 parent 90a041d commit c94d0af

File tree

4 files changed

+184
-180
lines changed

4 files changed

+184
-180
lines changed

jbmc/src/jbmc/all_properties.cpp

Lines changed: 132 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,32 @@ Author: Daniel Kroening, [email protected]
1717
#include <goto-checker/bmc_util.h>
1818
#include <goto-checker/report_util.h>
1919

20-
#include <util/xml.h>
2120
#include <util/json.h>
21+
#include <util/xml.h>
2222

2323
#include <solvers/prop/prop_conv.h>
2424
#include <solvers/sat/satcheck.h>
2525

26-
#include <goto-symex/build_goto_trace.h>
27-
#include <goto-programs/xml_goto_trace.h>
2826
#include <goto-programs/json_goto_trace.h>
27+
#include <goto-programs/xml_goto_trace.h>
28+
#include <goto-symex/build_goto_trace.h>
2929

3030
void bmc_all_propertiest::goal_covered(const cover_goalst::goalt &)
3131
{
3232
for(auto &g : goal_map)
3333
{
3434
// failed already?
35-
if(g.second.status==goalt::statust::FAILURE)
35+
if(g.second.status == goalt::statust::FAILURE)
3636
continue;
3737

3838
// check whether failed
3939
for(auto &c : g.second.instances)
4040
{
41-
literalt cond=c->cond_literal;
41+
literalt cond = c->cond_literal;
4242

4343
if(solver.l_get(cond).is_false())
4444
{
45-
g.second.status=goalt::statust::FAILURE;
45+
g.second.status = goalt::statust::FAILURE;
4646
build_goto_trace(bmc.equation, c, solver, bmc.ns, g.second.goto_trace);
4747
break;
4848
}
@@ -54,7 +54,7 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
5454
{
5555
status() << "Passing problem to " << solver.decision_procedure_text() << eom;
5656

57-
auto solver_start=std::chrono::steady_clock::now();
57+
auto solver_start = std::chrono::steady_clock::now();
5858

5959
convert_symex_target_equation(
6060
bmc.equation, bmc.prop_conv, get_message_handler());
@@ -65,13 +65,13 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
6565
forall_goto_functions(f_it, goto_functions)
6666
forall_goto_program_instructions(i_it, f_it->second.body)
6767
if(i_it->is_assert())
68-
goal_map[i_it->source_location.get_property_id()]=goalt(*i_it);
68+
goal_map[i_it->source_location.get_property_id()] = goalt(*i_it);
6969

7070
// get the conditions for these goals from formula
7171
// collect all 'instances' of the properties
72-
for(symex_target_equationt::SSA_stepst::iterator
73-
it=bmc.equation.SSA_steps.begin();
74-
it!=bmc.equation.SSA_steps.end();
72+
for(symex_target_equationt::SSA_stepst::iterator it =
73+
bmc.equation.SSA_steps.begin();
74+
it != bmc.equation.SSA_steps.end();
7575
it++)
7676
{
7777
if(it->is_assert())
@@ -101,29 +101,29 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
101101
{
102102
// Our goal is to falsify a property, i.e., we will
103103
// add the negation of the property as goal.
104-
literalt p=!solver.convert(g.second.as_expr());
104+
literalt p = !solver.convert(g.second.as_expr());
105105
cover_goals.add(p);
106106
}
107107

108108
status() << "Running " << solver.decision_procedure_text() << eom;
109109

110-
bool error=false;
110+
bool error = false;
111111

112112
const decision_proceduret::resultt result =
113113
cover_goals(get_message_handler());
114114

115-
if(result==decision_proceduret::resultt::D_ERROR)
115+
if(result == decision_proceduret::resultt::D_ERROR)
116116
{
117-
error=true;
117+
error = true;
118118
for(auto &g : goal_map)
119-
if(g.second.status==goalt::statust::UNKNOWN)
120-
g.second.status=goalt::statust::ERROR;
119+
if(g.second.status == goalt::statust::UNKNOWN)
120+
g.second.status = goalt::statust::ERROR;
121121
}
122122
else
123123
{
124124
for(auto &g : goal_map)
125-
if(g.second.status==goalt::statust::UNKNOWN)
126-
g.second.status=goalt::statust::SUCCESS;
125+
if(g.second.status == goalt::statust::UNKNOWN)
126+
g.second.status = goalt::statust::SUCCESS;
127127
}
128128

129129
{
@@ -141,155 +141,156 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
141141
if(error)
142142
return safety_checkert::resultt::ERROR;
143143

144-
bool safe=(cover_goals.number_covered()==0);
144+
bool safe = (cover_goals.number_covered() == 0);
145145

146146
if(safe)
147147
report_success(bmc.ui_message_handler); // legacy, might go away
148148
else
149149
report_failure(bmc.ui_message_handler); // legacy, might go away
150150

151-
return safe?safety_checkert::resultt::SAFE:safety_checkert::resultt::UNSAFE;
151+
return safe ? safety_checkert::resultt::SAFE
152+
: safety_checkert::resultt::UNSAFE;
152153
}
153154

154155
void bmc_all_propertiest::report(const cover_goalst &cover_goals)
155156
{
156157
switch(bmc.ui_message_handler.get_ui())
157158
{
158159
case ui_message_handlert::uit::PLAIN:
160+
{
161+
result() << "\n** Results:" << eom;
162+
163+
// collect goals in a vector
164+
std::vector<goal_mapt::const_iterator> goals;
165+
166+
for(auto g_it = goal_map.begin(); g_it != goal_map.end(); g_it++)
167+
goals.push_back(g_it);
168+
169+
// now determine an ordering for those goals:
170+
// 1. alphabetical ordering of file name
171+
// 2. numerical ordering of line number
172+
// 3. alphabetical ordering of goal ID
173+
std::sort(
174+
goals.begin(),
175+
goals.end(),
176+
[](goal_mapt::const_iterator git1, goal_mapt::const_iterator git2) {
177+
const auto &g1 = git1->second.source_location;
178+
const auto &g2 = git2->second.source_location;
179+
if(g1.get_file() != g2.get_file())
180+
return id2string(g1.get_file()) < id2string(g2.get_file());
181+
else if(!g1.get_line().empty() && !g2.get_line().empty())
182+
return std::stoul(id2string(g1.get_line())) <
183+
std::stoul(id2string(g2.get_line()));
184+
else
185+
return id2string(git1->first) < id2string(git2->first);
186+
});
187+
188+
// now show in the order we have determined
189+
190+
irep_idt previous_function;
191+
irep_idt current_file;
192+
for(const auto &g : goals)
159193
{
160-
result() << "\n** Results:" << eom;
161-
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-
irep_idt current_file;
191-
for(const auto &g : goals)
192-
{
193-
const auto &l = g->second.source_location;
194+
const auto &l = g->second.source_location;
194195

195-
if(l.get_function() != previous_function)
196+
if(l.get_function() != previous_function)
197+
{
198+
if(!previous_function.empty())
199+
result() << '\n';
200+
previous_function = l.get_function();
201+
if(!previous_function.empty())
196202
{
197-
if(!previous_function.empty())
198-
result() << '\n';
199-
previous_function = l.get_function();
200-
if(!previous_function.empty())
201-
{
202-
current_file = l.get_file();
203-
if(!current_file.empty())
204-
result() << current_file << ' ';
205-
if(!l.get_function().empty())
206-
result() << "function " << l.get_function();
207-
result() << eom;
208-
}
203+
current_file = l.get_file();
204+
if(!current_file.empty())
205+
result() << current_file << ' ';
206+
if(!l.get_function().empty())
207+
result() << "function " << l.get_function();
208+
result() << eom;
209209
}
210+
}
210211

211-
result() << faint << '[' << g->first << "] " << reset;
212-
213-
if(l.get_file() != current_file)
214-
result() << "file " << l.get_file() << ' ';
212+
result() << faint << '[' << g->first << "] " << reset;
215213

216-
if(!l.get_line().empty())
217-
result() << "line " << l.get_line() << ' ';
214+
if(l.get_file() != current_file)
215+
result() << "file " << l.get_file() << ' ';
218216

219-
result() << g->second.description << ": ";
217+
if(!l.get_line().empty())
218+
result() << "line " << l.get_line() << ' ';
220219

221-
if(g->second.status == goalt::statust::SUCCESS)
222-
result() << green;
223-
else
224-
result() << red;
220+
result() << g->second.description << ": ";
225221

226-
result() << g->second.status_string() << reset << eom;
227-
}
222+
if(g->second.status == goalt::statust::SUCCESS)
223+
result() << green;
224+
else
225+
result() << red;
228226

229-
if(bmc.options.get_bool_option("trace"))
230-
{
231-
for(const auto &g : goal_map)
232-
if(g.second.status==goalt::statust::FAILURE)
233-
{
234-
result() << "\n" << "Trace for " << g.first << ":" << "\n";
235-
show_goto_trace(
236-
result(), bmc.ns, g.second.goto_trace, bmc.trace_options());
237-
result() << eom;
238-
}
239-
}
227+
result() << g->second.status_string() << reset << eom;
228+
}
240229

241-
status() << "\n** " << cover_goals.number_covered()
242-
<< " of " << cover_goals.size() << " failed ("
243-
<< cover_goals.iterations() << " iteration"
244-
<< (cover_goals.iterations()==1?"":"s")
245-
<< ")" << eom;
230+
if(bmc.options.get_bool_option("trace"))
231+
{
232+
for(const auto &g : goal_map)
233+
if(g.second.status == goalt::statust::FAILURE)
234+
{
235+
result() << "\n"
236+
<< "Trace for " << g.first << ":"
237+
<< "\n";
238+
show_goto_trace(
239+
result(), bmc.ns, g.second.goto_trace, bmc.trace_options());
240+
result() << eom;
241+
}
246242
}
247-
break;
243+
244+
status() << "\n** " << cover_goals.number_covered() << " of "
245+
<< cover_goals.size() << " failed (" << cover_goals.iterations()
246+
<< " iteration" << (cover_goals.iterations() == 1 ? "" : "s")
247+
<< ")" << eom;
248+
}
249+
break;
248250

249251
case ui_message_handlert::uit::XML_UI:
252+
{
253+
for(const auto &g : goal_map)
250254
{
251-
for(const auto &g : goal_map)
252-
{
253-
xmlt xml_result(
254-
"result",
255-
{{"property", id2string(g.first)},
256-
{"status", g.second.status_string()}},
257-
{});
255+
xmlt xml_result(
256+
"result",
257+
{{"property", id2string(g.first)},
258+
{"status", g.second.status_string()}},
259+
{});
258260

259-
if(g.second.status==goalt::statust::FAILURE)
260-
convert(bmc.ns, g.second.goto_trace, xml_result.new_element());
261+
if(g.second.status == goalt::statust::FAILURE)
262+
convert(bmc.ns, g.second.goto_trace, xml_result.new_element());
261263

262-
result() << xml_result;
263-
}
264-
break;
264+
result() << xml_result;
265265
}
266+
break;
267+
}
266268

267-
case ui_message_handlert::uit::JSON_UI:
269+
case ui_message_handlert::uit::JSON_UI:
270+
{
271+
if(result().tellp() > 0)
272+
result() << eom; // force end of previous message
273+
json_stream_objectt &json_result =
274+
bmc.ui_message_handler.get_json_stream().push_back_stream_object();
275+
json_stream_arrayt &result_array =
276+
json_result.push_back_stream_array("result");
277+
278+
for(const auto &g : goal_map)
268279
{
269-
if(result().tellp() > 0)
270-
result() << eom; // force end of previous message
271-
json_stream_objectt &json_result =
272-
bmc.ui_message_handler.get_json_stream().push_back_stream_object();
273-
json_stream_arrayt &result_array =
274-
json_result.push_back_stream_array("result");
280+
json_stream_objectt &result = result_array.push_back_stream_object();
281+
result["property"] = json_stringt(g.first);
282+
result["description"] = json_stringt(g.second.description);
283+
result["status"] = json_stringt(g.second.status_string());
275284

276-
for(const auto &g : goal_map)
285+
if(g.second.status == goalt::statust::FAILURE)
277286
{
278-
json_stream_objectt &result = result_array.push_back_stream_object();
279-
result["property"] = json_stringt(g.first);
280-
result["description"] = json_stringt(g.second.description);
281-
result["status"]=json_stringt(g.second.status_string());
282-
283-
if(g.second.status==goalt::statust::FAILURE)
284-
{
285-
json_stream_arrayt &json_trace =
286-
result.push_back_stream_array("trace");
287-
convert<json_stream_arrayt>(
288-
bmc.ns, g.second.goto_trace, json_trace, bmc.trace_options());
289-
}
287+
json_stream_arrayt &json_trace = result.push_back_stream_array("trace");
288+
convert<json_stream_arrayt>(
289+
bmc.ns, g.second.goto_trace, json_trace, bmc.trace_options());
290290
}
291291
}
292-
break;
292+
}
293+
break;
293294
}
294295
}
295296

0 commit comments

Comments
 (0)