Skip to content

Commit aa9558c

Browse files
tautschnigpeterschrammel
authored andcommitted
Do not artificially separate message handler and uit
They were passed around independently, even though they originated from the very same object.
1 parent 0300f48 commit aa9558c

23 files changed

+96
-125
lines changed

jbmc/src/jbmc/jbmc_parse_options.cpp

+9-13
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,7 @@ int jbmc_parse_optionst::doit()
526526
path_strategy_chooser,
527527
options,
528528
goto_model,
529-
ui_message_handler.get_ui(),
530-
*this,
529+
ui_message_handler,
531530
configure_bmc);
532531
}
533532
else
@@ -560,15 +559,13 @@ int jbmc_parse_optionst::doit()
560559

561560
// The `configure_bmc` callback passed will enable enum-unwind-static if
562561
// applicable.
563-
return
564-
bmct::do_language_agnostic_bmc(
565-
path_strategy_chooser,
566-
options,
567-
lazy_goto_model,
568-
ui_message_handler.get_ui(),
569-
*this,
570-
configure_bmc,
571-
callback_after_symex);
562+
return bmct::do_language_agnostic_bmc(
563+
path_strategy_chooser,
564+
options,
565+
lazy_goto_model,
566+
ui_message_handler,
567+
configure_bmc,
568+
callback_after_symex);
572569
}
573570
}
574571

@@ -621,8 +618,7 @@ int jbmc_parse_optionst::get_goto_program(
621618
{
622619
class_hierarchyt hierarchy;
623620
hierarchy(lazy_goto_model.symbol_table);
624-
show_class_hierarchy(
625-
hierarchy, get_message_handler(), ui_message_handler.get_ui());
621+
show_class_hierarchy(hierarchy, ui_message_handler);
626622
return CPROVER_EXIT_SUCCESS;
627623
}
628624

jbmc/src/jdiff/java_syntactic_diff.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class java_syntactic_difft : public goto_difft
2121
const goto_modelt &_goto_model1,
2222
const goto_modelt &_goto_model2,
2323
const optionst &_options,
24-
message_handlert &_message_handler)
24+
ui_message_handlert &_message_handler)
2525
: goto_difft(_goto_model1, _goto_model2, _options, _message_handler)
2626
{
2727
}

jbmc/src/jdiff/jdiff_parse_options.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ int jdiff_parse_optionst::doit()
274274
}
275275

276276
java_syntactic_difft sd(
277-
goto_model1, goto_model2, options, get_message_handler());
278-
sd.set_ui(get_ui());
277+
goto_model1, goto_model2, options, ui_message_handler);
279278
sd();
280279
sd.output_functions();
281280

src/cbmc/all_properties.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
152152

153153
void bmc_all_propertiest::report(const cover_goalst &cover_goals)
154154
{
155-
switch(bmc.ui)
155+
switch(bmc.ui_message_handler.get_ui())
156156
{
157157
case ui_message_handlert::uit::PLAIN:
158158
{

src/cbmc/bmc.cpp

+19-15
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void bmct::error_trace()
5454
goto_tracet &goto_trace=safety_checkert::error_trace;
5555
build_goto_trace(equation, prop_conv, ns, goto_trace);
5656

57-
switch(ui)
57+
switch(ui_message_handler.get_ui())
5858
{
5959
case ui_message_handlert::uit::PLAIN:
6060
result() << "Counterexample:" << eom;
@@ -153,7 +153,7 @@ void bmct::report_success()
153153
{
154154
result() << "VERIFICATION SUCCESSFUL" << eom;
155155

156-
switch(ui)
156+
switch(ui_message_handler.get_ui())
157157
{
158158
case ui_message_handlert::uit::PLAIN:
159159
break;
@@ -180,7 +180,7 @@ void bmct::report_failure()
180180
{
181181
result() << "VERIFICATION FAILED" << eom;
182182

183-
switch(ui)
183+
switch(ui_message_handler.get_ui())
184184
{
185185
case ui_message_handlert::uit::PLAIN:
186186
break;
@@ -294,7 +294,7 @@ safety_checkert::resultt bmct::execute(
294294

295295
if(options.get_bool_option("show-vcc"))
296296
{
297-
show_vcc(options, get_message_handler(), ui, ns, equation);
297+
show_vcc(options, ui_message_handler, ns, equation);
298298
return safety_checkert::resultt::SAFE; // to indicate non-error
299299
}
300300

@@ -420,7 +420,7 @@ void bmct::show()
420420
{
421421
if(options.get_bool_option("show-vcc"))
422422
{
423-
show_vcc(options, get_message_handler(), ui, ns, equation);
423+
show_vcc(options, ui_message_handler, ns, equation);
424424
}
425425

426426
if(options.get_bool_option("program-only"))
@@ -478,15 +478,14 @@ int bmct::do_language_agnostic_bmc(
478478
const path_strategy_choosert &path_strategy_chooser,
479479
const optionst &opts,
480480
abstract_goto_modelt &model,
481-
const ui_message_handlert::uit &ui,
482-
messaget &message,
481+
ui_message_handlert &ui,
483482
std::function<void(bmct &, const symbol_tablet &)> driver_configure_bmc,
484483
std::function<bool(void)> callback_after_symex)
485484
{
486485
safety_checkert::resultt final_result = safety_checkert::resultt::UNKNOWN;
487486
safety_checkert::resultt tmp_result = safety_checkert::resultt::UNKNOWN;
488487
const symbol_tablet &symbol_table = model.get_symbol_table();
489-
message_handlert &mh = message.get_message_handler();
488+
messaget message(ui);
490489
std::unique_ptr<path_storaget> worklist;
491490
std::string strategy = opts.get_option("exploration-strategy");
492491
INVARIANT(
@@ -496,13 +495,15 @@ int bmct::do_language_agnostic_bmc(
496495
try
497496
{
498497
{
499-
cbmc_solverst solvers(opts, symbol_table, message.get_message_handler());
500-
solvers.set_ui(ui);
498+
cbmc_solverst solvers(
499+
opts,
500+
symbol_table,
501+
ui,
502+
ui.get_ui() == ui_message_handlert::uit::XML_UI);
501503
std::unique_ptr<cbmc_solverst::solvert> cbmc_solver;
502504
cbmc_solver = solvers.get_solver();
503505
prop_convt &pc = cbmc_solver->prop_conv();
504-
bmct bmc(opts, symbol_table, mh, pc, *worklist, callback_after_symex);
505-
bmc.set_ui(ui);
506+
bmct bmc(opts, symbol_table, ui, pc, *worklist, callback_after_symex);
506507
if(driver_configure_bmc)
507508
driver_configure_bmc(bmc, symbol_table);
508509
tmp_result = bmc.run(model);
@@ -546,16 +547,19 @@ int bmct::do_language_agnostic_bmc(
546547
<< "Starting new path (" << worklist->size()
547548
<< " to go)\n"
548549
<< message.eom;
549-
cbmc_solverst solvers(opts, symbol_table, message.get_message_handler());
550-
solvers.set_ui(ui);
550+
cbmc_solverst solvers(
551+
opts,
552+
symbol_table,
553+
ui,
554+
ui.get_ui() == ui_message_handlert::uit::XML_UI);
551555
std::unique_ptr<cbmc_solverst::solvert> cbmc_solver;
552556
cbmc_solver = solvers.get_solver();
553557
prop_convt &pc = cbmc_solver->prop_conv();
554558
path_storaget::patht &resume = worklist->peek();
555559
path_explorert pe(
556560
opts,
557561
symbol_table,
558-
mh,
562+
ui,
559563
pc,
560564
resume.equation,
561565
resume.state,

src/cbmc/bmc.h

+9-12
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class bmct:public safety_checkert
6666
bmct(
6767
const optionst &_options,
6868
const symbol_tablet &outer_symbol_table,
69-
message_handlert &_message_handler,
69+
ui_message_handlert &_message_handler,
7070
prop_convt &_prop_conv,
7171
path_storaget &_path_storage,
7272
std::function<bool(void)> callback_after_symex)
@@ -83,7 +83,7 @@ class bmct:public safety_checkert
8383
options,
8484
path_storage),
8585
prop_conv(_prop_conv),
86-
ui(ui_message_handlert::uit::PLAIN),
86+
ui_message_handler(_message_handler),
8787
driver_callback_after_symex(callback_after_symex)
8888
{
8989
symex.constant_propagation=options.get_bool_option("propagation");
@@ -103,8 +103,6 @@ class bmct:public safety_checkert
103103
safety_checkert::resultt execute(abstract_goto_modelt &);
104104
virtual ~bmct() { }
105105

106-
void set_ui(ui_message_handlert::uit _ui) { ui=_ui; }
107-
108106
// the safety_checkert interface
109107
virtual resultt operator()(
110108
const goto_functionst &goto_functions)
@@ -127,10 +125,9 @@ class bmct:public safety_checkert
127125
const path_strategy_choosert &path_strategy_chooser,
128126
const optionst &opts,
129127
abstract_goto_modelt &goto_model,
130-
const ui_message_handlert::uit &ui,
131-
messaget &message,
132-
std::function<void(bmct &, const symbol_tablet &)>
133-
driver_configure_bmc = nullptr,
128+
ui_message_handlert &ui,
129+
std::function<void(bmct &, const symbol_tablet &)> driver_configure_bmc =
130+
nullptr,
134131
std::function<bool(void)> callback_after_symex = nullptr);
135132

136133
protected:
@@ -144,7 +141,7 @@ class bmct:public safety_checkert
144141
bmct(
145142
const optionst &_options,
146143
const symbol_tablet &outer_symbol_table,
147-
message_handlert &_message_handler,
144+
ui_message_handlert &_message_handler,
148145
prop_convt &_prop_conv,
149146
symex_target_equationt &_equation,
150147
path_storaget &_path_storage,
@@ -162,7 +159,7 @@ class bmct:public safety_checkert
162159
options,
163160
path_storage),
164161
prop_conv(_prop_conv),
165-
ui(ui_message_handlert::uit::PLAIN),
162+
ui_message_handler(_message_handler),
166163
driver_callback_after_symex(callback_after_symex)
167164
{
168165
symex.constant_propagation = options.get_bool_option("propagation");
@@ -186,7 +183,7 @@ class bmct:public safety_checkert
186183
prop_convt &prop_conv;
187184
std::unique_ptr<memory_model_baset> memory_model;
188185
// use gui format
189-
ui_message_handlert::uit ui;
186+
ui_message_handlert &ui_message_handler;
190187

191188
virtual decision_proceduret::resultt
192189
run_decision_procedure(prop_convt &prop_conv);
@@ -259,7 +256,7 @@ class path_explorert : public bmct
259256
path_explorert(
260257
const optionst &_options,
261258
const symbol_tablet &outer_symbol_table,
262-
message_handlert &_message_handler,
259+
ui_message_handlert &_message_handler,
263260
prop_convt &_prop_conv,
264261
symex_target_equationt &saved_equation,
265262
const goto_symex_statet &saved_state,

src/cbmc/bmc_cover.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ bool bmc_covert::operator()()
261261
if(g.second.satisfied)
262262
goals_covered++;
263263

264-
switch(bmc.ui)
264+
switch(bmc.ui_message_handler.get_ui())
265265
{
266266
case ui_message_handlert::uit::PLAIN:
267267
{
@@ -406,7 +406,7 @@ bool bmc_covert::operator()()
406406
<< (cover_goals.iterations()==1?"":"s")
407407
<< eom;
408408

409-
if(bmc.ui==ui_message_handlert::uit::PLAIN)
409+
if(bmc.ui_message_handler.get_ui() == ui_message_handlert::uit::PLAIN)
410410
{
411411
result() << "Test suite:" << '\n';
412412

src/cbmc/cbmc_parse_options.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,7 @@ int cbmc_parse_optionst::doit()
530530
return CPROVER_EXIT_SET_PROPERTIES_FAILED;
531531

532532
return bmct::do_language_agnostic_bmc(
533-
path_strategy_chooser,
534-
options,
535-
goto_model,
536-
ui_message_handler.get_ui(),
537-
*this);
533+
path_strategy_chooser, options, goto_model, ui_message_handler);
538534
}
539535

540536
bool cbmc_parse_optionst::set_properties()

src/cbmc/cbmc_solvers.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_default()
7272
solver->set_prop(util_make_unique<satcheckt>());
7373
}
7474

75-
solver->prop().set_message_handler(get_message_handler());
75+
solver->prop().set_message_handler(message_handler);
7676

7777
auto bv_pointers = util_make_unique<bv_pointerst>(ns, solver->prop());
7878

@@ -92,7 +92,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_dimacs()
9292
no_incremental_check();
9393

9494
auto prop=util_make_unique<dimacs_cnft>();
95-
prop->set_message_handler(get_message_handler());
95+
prop->set_message_handler(message_handler);
9696

9797
std::string filename=options.get_option("outfile");
9898

@@ -113,12 +113,12 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_bv_refinement()
113113
return util_make_unique<satcheck_no_simplifiert>();
114114
}();
115115

116-
prop->set_message_handler(get_message_handler());
116+
prop->set_message_handler(message_handler);
117117

118118
bv_refinementt::infot info;
119119
info.ns=&ns;
120120
info.prop=prop.get();
121-
info.output_xml = ui == ui_message_handlert::uit::XML_UI;
121+
info.output_xml = output_xml_in_refinement;
122122

123123
// we allow setting some parameters
124124
if(options.get_bool_option("max-node-refinement"))
@@ -141,10 +141,10 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_string_refinement()
141141
string_refinementt::infot info;
142142
info.ns=&ns;
143143
auto prop=util_make_unique<satcheck_no_simplifiert>();
144-
prop->set_message_handler(get_message_handler());
144+
prop->set_message_handler(message_handler);
145145
info.prop=prop.get();
146146
info.refinement_bound=DEFAULT_MAX_NB_REFINEMENT;
147-
info.output_xml = ui == ui_message_handlert::uit::XML_UI;
147+
info.output_xml = output_xml_in_refinement;
148148
if(options.get_bool_option("max-node-refinement"))
149149
info.max_node_refinement=
150150
options.get_unsigned_int_option("max-node-refinement");
@@ -197,7 +197,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_smt2(
197197
if(options.get_bool_option("fpa"))
198198
smt2_conv->use_FPA_theory=true;
199199

200-
smt2_conv->set_message_handler(get_message_handler());
200+
smt2_conv->set_message_handler(message_handler);
201201

202202
return util_make_unique<solvert>(std::move(smt2_conv));
203203
}
@@ -226,7 +226,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_smt2(
226226
if(options.get_bool_option("fpa"))
227227
smt2_conv->use_FPA_theory=true;
228228

229-
smt2_conv->set_message_handler(get_message_handler());
229+
smt2_conv->set_message_handler(message_handler);
230230

231231
return util_make_unique<solvert>(std::move(smt2_conv), std::move(out));
232232
}

0 commit comments

Comments
 (0)