Skip to content

Commit f4a8b0c

Browse files
Replace cout in show_properties
All output should be printed to message streams
1 parent b0eb45e commit f4a8b0c

File tree

7 files changed

+27
-18
lines changed

7 files changed

+27
-18
lines changed

src/cbmc/cbmc_parse_options.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ int cbmc_parse_optionst::doit()
534534
if(cmdline.isset("show-claims") || // will go away
535535
cmdline.isset("show-properties")) // use this one
536536
{
537-
show_properties(goto_model, ui_message_handler.get_ui());
537+
show_properties(
538+
goto_model, get_message_handler(), ui_message_handler.get_ui());
538539
return CPROVER_EXIT_SUCCESS;
539540
}
540541

src/clobber/clobber_parse_options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int clobber_parse_optionst::doit()
150150

151151
if(cmdline.isset("show-properties"))
152152
{
153-
show_properties(goto_model, get_ui());
153+
show_properties(goto_model, get_message_handler(), get_ui());
154154
return 0;
155155
}
156156

src/goto-analyzer/goto_analyzer_parse_options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
592592

593593
if(cmdline.isset("show-properties"))
594594
{
595-
show_properties(goto_model, get_ui());
595+
show_properties(goto_model, get_message_handler(), get_ui());
596596
return CPROVER_EXIT_SUCCESS;
597597
}
598598

src/goto-instrument/goto_instrument_parse_options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ int goto_instrument_parse_optionst::doit()
532532
cmdline.isset("show-properties"))
533533
{
534534
const namespacet ns(goto_model.symbol_table);
535-
show_properties(goto_model, get_ui());
535+
show_properties(goto_model, get_message_handler(), get_ui());
536536
return CPROVER_EXIT_SUCCESS;
537537
}
538538

src/goto-programs/show_properties.cpp

+17-13
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@ optionalt<source_locationt> find_property(
4646
return { };
4747
}
4848

49-
5049
void show_properties(
5150
const namespacet &ns,
5251
const irep_idt &identifier,
52+
message_handlert &message_handler,
5353
ui_message_handlert::uit ui,
5454
const goto_programt &goto_program)
5555
{
56+
messaget msg(message_handler);
5657
for(const auto &ins : goto_program.instructions)
5758
{
5859
if(!ins.is_assert())
@@ -83,7 +84,7 @@ void show_properties(
8384
xml_property.new_element("expression").data=
8485
from_expr(ns, identifier, ins.guard);
8586

86-
std::cout << xml_property << '\n';
87+
msg.result() << xml_property;
8788
}
8889
break;
8990

@@ -92,14 +93,13 @@ void show_properties(
9293
break;
9394

9495
case ui_message_handlert::uit::PLAIN:
95-
std::cout << "Property " << property_id << ":\n";
96+
msg.result() << "Property " << property_id << ":\n";
9697

97-
std::cout << " " << ins.source_location << '\n'
98-
<< " " << description << '\n'
99-
<< " " << from_expr(ns, identifier, ins.guard)
100-
<< '\n';
98+
msg.result() << " " << ins.source_location << '\n'
99+
<< " " << description << '\n'
100+
<< " " << from_expr(ns, identifier, ins.guard) << '\n';
101101

102-
std::cout << '\n';
102+
msg.result() << messaget::eom;
103103
break;
104104

105105
default:
@@ -147,8 +147,10 @@ void show_properties_json(
147147

148148
void show_properties_json(
149149
const namespacet &ns,
150+
message_handlert &message_handler,
150151
const goto_functionst &goto_functions)
151152
{
153+
messaget msg(message_handler);
152154
json_arrayt json_properties;
153155

154156
for(const auto &fct : goto_functions.function_map)
@@ -161,29 +163,31 @@ void show_properties_json(
161163

162164
json_objectt json_result;
163165
json_result["properties"] = json_properties;
164-
std::cout << ",\n" << json_result;
166+
msg.result() << json_result;
165167
}
166168

167169
void show_properties(
168170
const namespacet &ns,
171+
message_handlert &message_handler,
169172
ui_message_handlert::uit ui,
170173
const goto_functionst &goto_functions)
171174
{
172175
if(ui == ui_message_handlert::uit::JSON_UI)
173-
show_properties_json(ns, goto_functions);
176+
show_properties_json(ns, message_handler, goto_functions);
174177
else
175178
for(const auto &fct : goto_functions.function_map)
176179
if(!fct.second.is_inlined())
177-
show_properties(ns, fct.first, ui, fct.second.body);
180+
show_properties(ns, fct.first, message_handler, ui, fct.second.body);
178181
}
179182

180183
void show_properties(
181184
const goto_modelt &goto_model,
185+
message_handlert &message_handler,
182186
ui_message_handlert::uit ui)
183187
{
184188
const namespacet ns(goto_model.symbol_table);
185189
if(ui == ui_message_handlert::uit::JSON_UI)
186-
show_properties_json(ns, goto_model.goto_functions);
190+
show_properties_json(ns, message_handler, goto_model.goto_functions);
187191
else
188-
show_properties(ns, ui, goto_model.goto_functions);
192+
show_properties(ns, message_handler, ui, goto_model.goto_functions);
189193
}

src/goto-programs/show_properties.h

+3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ class namespacet;
1919
class goto_modelt;
2020
class symbol_tablet;
2121
class goto_functionst;
22+
class message_handlert;
2223

2324
void show_properties(
2425
const goto_modelt &,
26+
message_handlert &message_handler,
2527
ui_message_handlert::uit ui);
2628

2729
void show_properties(
2830
const namespacet &ns,
31+
message_handlert &message_handler,
2932
ui_message_handlert::uit ui,
3033
const goto_functionst &goto_functions);
3134

src/jbmc/jbmc_parse_options.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ int jbmc_parse_optionst::doit()
484484

485485
if(cmdline.isset("show-properties"))
486486
{
487-
show_properties(goto_model, ui_message_handler.get_ui());
487+
show_properties(
488+
goto_model, get_message_handler(), ui_message_handler.get_ui());
488489
return 0; // should contemplate EX_OK from sysexits.h
489490
}
490491

0 commit comments

Comments
 (0)