Skip to content

Commit d902ec8

Browse files
Replace cout by message stream in show-goto-functions
1 parent d970673 commit d902ec8

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

src/cbmc/cbmc_parse_options.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ int cbmc_parse_optionst::get_goto_program(
642642
{
643643
show_goto_functions(
644644
goto_model,
645+
get_message_handler(),
645646
ui_message_handler.get_ui(),
646647
cmdline.isset("list-goto-functions"));
647648
return CPROVER_EXIT_SUCCESS;

src/goto-diff/goto_diff_parse_options.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,12 @@ int goto_diff_parse_optionst::doit()
293293
{
294294
show_goto_functions(
295295
goto_model1,
296+
get_message_handler(),
296297
ui_message_handler.get_ui(),
297298
cmdline.isset("list-goto-functions"));
298299
show_goto_functions(
299300
goto_model2,
301+
get_message_handler(),
300302
ui_message_handler.get_ui(),
301303
cmdline.isset("list-goto-functions"));
302304
return 0;

src/goto-instrument/goto_instrument_parse_options.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ int goto_instrument_parse_optionst::doit()
581581
{
582582
show_goto_functions(
583583
goto_model,
584+
get_message_handler(),
584585
ui_message_handler.get_ui(),
585586
cmdline.isset("list-goto-functions"));
586587
return CPROVER_EXIT_SUCCESS;

src/goto-programs/show_goto_functions.cpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,25 @@ Author: Peter Schrammel
2929

3030
void show_goto_functions(
3131
const namespacet &ns,
32+
message_handlert &message_handler,
3233
ui_message_handlert::uit ui,
3334
const goto_functionst &goto_functions,
3435
bool list_only)
3536
{
37+
messaget msg(message_handler);
3638
switch(ui)
3739
{
3840
case ui_message_handlert::uit::XML_UI:
3941
{
4042
show_goto_functions_xmlt xml_show_functions(ns, list_only);
41-
xml_show_functions(goto_functions, std::cout);
43+
msg.status() << xml_show_functions.convert(goto_functions);
4244
}
4345
break;
4446

4547
case ui_message_handlert::uit::JSON_UI:
4648
{
4749
show_goto_functions_jsont json_show_functions(ns, list_only);
48-
json_show_functions(goto_functions, std::cout);
50+
msg.status() << json_show_functions.convert(goto_functions);
4951
}
5052
break;
5153

@@ -55,27 +57,32 @@ void show_goto_functions(
5557
for(const auto &fun : goto_functions.function_map)
5658
{
5759
const symbolt &symbol = ns.lookup(fun.first);
58-
std::cout << '\n'
59-
<< symbol.display_name() << " /* " << symbol.name
60-
<< (fun.second.body_available() ? ""
61-
: ", body not available")
62-
<< " */";
60+
msg.status() << '\n'
61+
<< symbol.display_name() << " /* " << symbol.name
62+
<< (fun.second.body_available() ? ""
63+
: ", body not available")
64+
<< " */";
6365
}
6466

65-
std::cout << std::endl;
67+
msg.status() << messaget::eom;
6668
}
6769
else
68-
goto_functions.output(ns, std::cout);
70+
{
71+
goto_functions.output(ns, msg.status());
72+
msg.status() << messaget::eom;
73+
}
6974

7075
break;
7176
}
7277
}
7378

7479
void show_goto_functions(
7580
const goto_modelt &goto_model,
81+
message_handlert &message_handler,
7682
ui_message_handlert::uit ui,
7783
bool list_only)
7884
{
7985
const namespacet ns(goto_model.symbol_table);
80-
show_goto_functions(ns, ui, goto_model.goto_functions, list_only);
86+
show_goto_functions(
87+
ns, message_handler, ui, goto_model.goto_functions, list_only);
8188
}

src/goto-programs/show_goto_functions.h

+2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ class goto_functionst;
3030

3131
void show_goto_functions(
3232
const namespacet &ns,
33+
message_handlert &message_handler,
3334
ui_message_handlert::uit ui,
3435
const goto_functionst &goto_functions,
3536
bool list_only = false);
3637

3738
void show_goto_functions(
3839
const goto_modelt &,
40+
message_handlert &message_handler,
3941
ui_message_handlert::uit ui,
4042
bool list_only = false);
4143

src/jbmc/jbmc_parse_options.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ int jbmc_parse_optionst::get_goto_program(
607607
{
608608
show_goto_functions(
609609
*goto_model,
610+
get_message_handler(),
610611
ui_message_handler.get_ui(),
611612
cmdline.isset("list-goto-functions"));
612613
return 0;

0 commit comments

Comments
 (0)