Skip to content

Commit d703c21

Browse files
author
Daniel Kroening
committed
goto-analyzer: default result report now uses messaget
Splitting 'report into text file' and 'report onto console' enables tweaking the latter, e.g., by adding colors.
1 parent b01f1f6 commit d703c21

File tree

2 files changed

+61
-10
lines changed

2 files changed

+61
-10
lines changed

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
178178
options.set_option("dot", true);
179179
options.set_option("outfile", cmdline.get_value("dot"));
180180
}
181-
else
182-
{
183-
options.set_option("text", true);
184-
options.set_option("outfile", "-");
185-
}
186181

187182
// The use should either select:
188183
// 1. a specific analysis, or
@@ -589,11 +584,13 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
589584

590585
// Output file factory
591586
const std::string outfile=options.get_option("outfile");
587+
592588
std::ofstream output_stream;
593-
if(!(outfile=="-"))
589+
if(outfile != "-" && outfile != "")
594590
output_stream.open(outfile);
595591

596-
std::ostream &out((outfile=="-") ? std::cout : output_stream);
592+
std::ostream &out(
593+
(outfile == "-" || outfile == "") ? std::cout : output_stream);
597594

598595
if(!out)
599596
{

src/goto-analyzer/static_verifier.cpp

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,8 @@ bool static_verifier(
143143
m.status() << "Writing XML report" << messaget::eom;
144144
out << xml_result;
145145
}
146-
else
146+
else if(options.get_bool_option("text"))
147147
{
148-
INVARIANT(options.get_bool_option("text"), "Other output formats handled");
149-
150148
forall_goto_functions(f_it, goto_model.goto_functions)
151149
{
152150
m.progress() << "Checking " << f_it->first << messaget::eom;
@@ -203,6 +201,62 @@ bool static_verifier(
203201
out << '\n';
204202
}
205203
}
204+
else
205+
{
206+
forall_goto_functions(f_it, goto_model.goto_functions)
207+
{
208+
if(!f_it->second.body.has_assertion())
209+
continue;
210+
211+
m.result() << "******** Function " << f_it->first << messaget::eom;
212+
213+
forall_goto_program_instructions(i_it, f_it->second.body)
214+
{
215+
if(!i_it->is_assert())
216+
continue;
217+
218+
exprt e(i_it->guard);
219+
auto dp = ai.abstract_state_before(i_it);
220+
const ai_domain_baset &domain(*dp);
221+
domain.ai_simplify(e, ns);
222+
223+
m.result() << '[' << i_it->source_location.get_property_id() << ']'
224+
<< ' ';
225+
226+
out << i_it->source_location;
227+
228+
if(!i_it->source_location.get_comment().empty())
229+
m.result() << ", " << i_it->source_location.get_comment();
230+
231+
m.result() << ": ";
232+
233+
if(e.is_true())
234+
{
235+
m.result() << "Success";
236+
pass++;
237+
}
238+
else if(e.is_false())
239+
{
240+
m.result() << "Failure (if reachable)";
241+
fail++;
242+
}
243+
else if(domain.is_bottom())
244+
{
245+
m.result() << "Success (unreachable)";
246+
pass++;
247+
}
248+
else
249+
{
250+
m.result() << "Unknown";
251+
unknown++;
252+
}
253+
254+
m.result() << messaget::eom;
255+
}
256+
257+
m.result() << messaget::eom;
258+
}
259+
}
206260

207261
m.status() << "Summary: "
208262
<< pass << " pass, "

0 commit comments

Comments
 (0)