Skip to content

Commit 8234d57

Browse files
Clang-format
1 parent fc84151 commit 8234d57

File tree

4 files changed

+186
-182
lines changed

4 files changed

+186
-182
lines changed

jbmc/src/jbmc/all_properties.cpp

Lines changed: 134 additions & 133 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

23-
#include <solvers/sat/satcheck.h>
2423
#include <solvers/prop/literal_expr.h>
24+
#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
}
@@ -56,7 +56,7 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
5656

5757
solver.set_message_handler(get_message_handler());
5858

59-
auto solver_start=std::chrono::steady_clock::now();
59+
auto solver_start = std::chrono::steady_clock::now();
6060

6161
convert_symex_target_equation(
6262
bmc.equation, bmc.prop_conv, get_message_handler());
@@ -67,13 +67,13 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
6767
forall_goto_functions(f_it, goto_functions)
6868
forall_goto_program_instructions(i_it, f_it->second.body)
6969
if(i_it->is_assert())
70-
goal_map[i_it->source_location.get_property_id()]=goalt(*i_it);
70+
goal_map[i_it->source_location.get_property_id()] = goalt(*i_it);
7171

7272
// get the conditions for these goals from formula
7373
// collect all 'instances' of the properties
74-
for(symex_target_equationt::SSA_stepst::iterator
75-
it=bmc.equation.SSA_steps.begin();
76-
it!=bmc.equation.SSA_steps.end();
74+
for(symex_target_equationt::SSA_stepst::iterator it =
75+
bmc.equation.SSA_steps.begin();
76+
it != bmc.equation.SSA_steps.end();
7777
it++)
7878
{
7979
if(it->is_assert())
@@ -104,28 +104,28 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
104104
{
105105
// Our goal is to falsify a property, i.e., we will
106106
// add the negation of the property as goal.
107-
literalt p=!solver.convert(g.second.as_expr());
107+
literalt p = !solver.convert(g.second.as_expr());
108108
cover_goals.add(p);
109109
}
110110

111111
status() << "Running " << solver.decision_procedure_text() << eom;
112112

113-
bool error=false;
113+
bool error = false;
114114

115-
decision_proceduret::resultt result=cover_goals();
115+
decision_proceduret::resultt result = cover_goals();
116116

117-
if(result==decision_proceduret::resultt::D_ERROR)
117+
if(result == decision_proceduret::resultt::D_ERROR)
118118
{
119-
error=true;
119+
error = true;
120120
for(auto &g : goal_map)
121-
if(g.second.status==goalt::statust::UNKNOWN)
122-
g.second.status=goalt::statust::ERROR;
121+
if(g.second.status == goalt::statust::UNKNOWN)
122+
g.second.status = goalt::statust::ERROR;
123123
}
124124
else
125125
{
126126
for(auto &g : goal_map)
127-
if(g.second.status==goalt::statust::UNKNOWN)
128-
g.second.status=goalt::statust::SUCCESS;
127+
if(g.second.status == goalt::statust::UNKNOWN)
128+
g.second.status = goalt::statust::SUCCESS;
129129
}
130130

131131
{
@@ -143,155 +143,156 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
143143
if(error)
144144
return safety_checkert::resultt::ERROR;
145145

146-
bool safe=(cover_goals.number_covered()==0);
146+
bool safe = (cover_goals.number_covered() == 0);
147147

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

153-
return safe?safety_checkert::resultt::SAFE:safety_checkert::resultt::UNSAFE;
153+
return safe ? safety_checkert::resultt::SAFE
154+
: safety_checkert::resultt::UNSAFE;
154155
}
155156

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

197-
if(l.get_function() != previous_function)
198+
if(l.get_function() != previous_function)
199+
{
200+
if(!previous_function.empty())
201+
result() << '\n';
202+
previous_function = l.get_function();
203+
if(!previous_function.empty())
198204
{
199-
if(!previous_function.empty())
200-
result() << '\n';
201-
previous_function = l.get_function();
202-
if(!previous_function.empty())
203-
{
204-
current_file = l.get_file();
205-
if(!current_file.empty())
206-
result() << current_file << ' ';
207-
if(!l.get_function().empty())
208-
result() << "function " << l.get_function();
209-
result() << eom;
210-
}
205+
current_file = l.get_file();
206+
if(!current_file.empty())
207+
result() << current_file << ' ';
208+
if(!l.get_function().empty())
209+
result() << "function " << l.get_function();
210+
result() << eom;
211211
}
212+
}
212213

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

218-
if(!l.get_line().empty())
219-
result() << "line " << l.get_line() << ' ';
216+
if(l.get_file() != current_file)
217+
result() << "file " << l.get_file() << ' ';
220218

221-
result() << g->second.description << ": ";
219+
if(!l.get_line().empty())
220+
result() << "line " << l.get_line() << ' ';
222221

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

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

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

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

251253
case ui_message_handlert::uit::XML_UI:
254+
{
255+
for(const auto &g : goal_map)
252256
{
253-
for(const auto &g : goal_map)
254-
{
255-
xmlt xml_result(
256-
"result",
257-
{{"property", id2string(g.first)},
258-
{"status", g.second.status_string()}},
259-
{});
257+
xmlt xml_result(
258+
"result",
259+
{{"property", id2string(g.first)},
260+
{"status", g.second.status_string()}},
261+
{});
260262

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

264-
result() << xml_result;
265-
}
266-
break;
266+
result() << xml_result;
267267
}
268+
break;
269+
}
268270

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

278-
for(const auto &g : goal_map)
287+
if(g.second.status == goalt::statust::FAILURE)
279288
{
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());
284-
285-
if(g.second.status==goalt::statust::FAILURE)
286-
{
287-
json_stream_arrayt &json_trace =
288-
result.push_back_stream_array("trace");
289-
convert<json_stream_arrayt>(
290-
bmc.ns, g.second.goto_trace, json_trace, bmc.trace_options());
291-
}
289+
json_stream_arrayt &json_trace = result.push_back_stream_array("trace");
290+
convert<json_stream_arrayt>(
291+
bmc.ns, g.second.goto_trace, json_trace, bmc.trace_options());
292292
}
293293
}
294-
break;
294+
}
295+
break;
295296
}
296297
}
297298

0 commit comments

Comments
 (0)