Skip to content

Commit bc4503d

Browse files
authored
Merge pull request #3022 from diffblue/goto-analyzer-use-messaget
goto-analyzer: default result report now uses messaget
2 parents ca235a9 + 2c19624 commit bc4503d

File tree

4 files changed

+78
-31
lines changed

4 files changed

+78
-31
lines changed

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 4 additions & 9 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
@@ -586,14 +581,15 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
586581

587582
if(options.get_bool_option("general-analysis"))
588583
{
589-
590584
// Output file factory
591585
const std::string outfile=options.get_option("outfile");
586+
592587
std::ofstream output_stream;
593-
if(!(outfile=="-"))
588+
if(outfile != "-" && !outfile.empty())
594589
output_stream.open(outfile);
595590

596-
std::ostream &out((outfile=="-") ? std::cout : output_stream);
591+
std::ostream &out(
592+
(outfile == "-" || outfile.empty()) ? std::cout : output_stream);
597593

598594
if(!out)
599595
{
@@ -614,7 +610,6 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
614610
return CPROVER_EXIT_INTERNAL_ERROR;
615611
}
616612

617-
618613
// Run
619614
status() << "Computing abstract states" << eom;
620615
(*analyzer)(goto_model);

src/goto-analyzer/static_show_domain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool static_show_domain(
4545
}
4646
else
4747
{
48-
INVARIANT(options.get_bool_option("text"), "Other output formats handled");
48+
// 'text' or console output
4949
ai.output(goto_model, out);
5050
}
5151

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+
m.result() << 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, "

src/goto-analyzer/unreachable_instructions.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ bool static_unreachable_instructions(
233233
}
234234
else
235235
{
236-
INVARIANT(options.get_bool_option("text"),
237-
"Other output formats handled");
236+
// text or console
238237
output_dead_plain(ns, f_it->second.body, dead_map, out);
239238
}
240239
}
@@ -342,14 +341,13 @@ static void list_functions(
342341
// this to macros/asm renaming
343342
continue;
344343

345-
if(options.get_bool_option("text"))
344+
if(options.get_bool_option("json"))
346345
{
347-
os << concat_dir_file(
348-
id2string(first_location.get_working_directory()),
349-
id2string(first_location.get_file())) << " "
350-
<< decl.base_name << " "
351-
<< first_location.get_line() << " "
352-
<< last_location.get_line() << "\n";
346+
json_output_function(
347+
decl.base_name,
348+
first_location,
349+
last_location,
350+
json_result);
353351
}
354352
else if(options.get_bool_option("xml"))
355353
{
@@ -360,11 +358,15 @@ static void list_functions(
360358
xml_result);
361359
}
362360
else
363-
json_output_function(
364-
decl.base_name,
365-
first_location,
366-
last_location,
367-
json_result);
361+
{
362+
// text or console
363+
os << concat_dir_file(
364+
id2string(first_location.get_working_directory()),
365+
id2string(first_location.get_file())) << " "
366+
<< decl.base_name << " "
367+
<< first_location.get_line() << " "
368+
<< last_location.get_line() << "\n";
369+
}
368370
}
369371

370372
if(options.get_bool_option("json") && !json_result.array.empty())
@@ -381,8 +383,6 @@ void unreachable_functions(
381383
optionst options;
382384
if(json)
383385
options.set_option("json", true);
384-
else
385-
options.set_option("text", true);
386386

387387
std::unordered_set<irep_idt> called = compute_called_functions(goto_model);
388388

@@ -397,8 +397,6 @@ void reachable_functions(
397397
optionst options;
398398
if(json)
399399
options.set_option("json", true);
400-
else
401-
options.set_option("text", true);
402400

403401
std::unordered_set<irep_idt> called = compute_called_functions(goto_model);
404402

0 commit comments

Comments
 (0)