Skip to content

Commit d933332

Browse files
committed
A decision_proceduret isn't a messaget
Some derived classes may want to generate output, but then it's safe for them to be messaget's.
1 parent 85a2a6a commit d933332

15 files changed

+40
-44
lines changed

src/cbmc/all_properties.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
5454
{
5555
status() << "Passing problem to " << solver.decision_procedure_text() << eom;
5656

57-
solver.set_message_handler(get_message_handler());
58-
5957
auto solver_start=std::chrono::steady_clock::now();
6058

6159
convert_symex_target_equation(

src/cbmc/bmc.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ decision_proceduret::resultt bmct::run_decision_procedure()
4747
status() << "Passing problem to "
4848
<< prop_conv.decision_procedure_text() << eom;
4949

50-
prop_conv.set_message_handler(get_message_handler());
51-
5250
auto solver_start = std::chrono::steady_clock::now();
5351

5452
convert_symex_target_equation(equation, prop_conv, get_message_handler());
@@ -207,8 +205,6 @@ safety_checkert::resultt bmct::run(
207205

208206
safety_checkert::resultt bmct::decide(const goto_functionst &goto_functions)
209207
{
210-
prop_conv.set_message_handler(get_message_handler());
211-
212208
if(options.get_bool_option("stop-on-fail"))
213209
return stop_on_fail();
214210
else

src/cbmc/bmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class bmct:public safety_checkert
7575
options(_options),
7676
outer_symbol_table(outer_symbol_table),
7777
ns(outer_symbol_table, symex_symbol_table),
78-
equation(),
78+
equation(_message_handler),
7979
path_storage(_path_storage),
8080
symex(
8181
_message_handler,

src/cbmc/bmc_cover.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ bool bmc_covert::operator()()
189189
{
190190
status() << "Passing problem to " << solver.decision_procedure_text() << eom;
191191

192-
solver.set_message_handler(get_message_handler());
193-
194192
auto solver_start=std::chrono::steady_clock::now();
195193

196194
// Collect _all_ goals in `goal_map'.

src/cbmc/fault_localization.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ fault_localizationt::run_decision_procedure(prop_convt &prop_conv)
247247
status() << "Passing problem to "
248248
<< prop_conv.decision_procedure_text() << eom;
249249

250-
prop_conv.set_message_handler(bmc.get_message_handler());
251-
252250
auto solver_start=std::chrono::steady_clock::now();
253251

254252
convert_symex_target_equation(

src/goto-checker/multi_path_symex_only_checker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ multi_path_symex_only_checkert::multi_path_symex_only_checkert(
2626
: incremental_goto_checkert(options, ui_message_handler),
2727
goto_model(goto_model),
2828
ns(goto_model.get_symbol_table(), symex_symbol_table),
29+
equation(ui_message_handler),
2930
symex(
3031
ui_message_handler,
3132
goto_model.get_symbol_table(),

src/goto-checker/single_path_symex_only_checker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ operator()(propertiest &properties)
3939

4040
{
4141
// Put initial state into the work list
42-
symex_target_equationt equation;
42+
symex_target_equationt equation(ui_message_handler);
4343
symex_bmct symex(
4444
ui_message_handler,
4545
goto_model.get_symbol_table(),

src/goto-checker/solver_factory.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ solver_factoryt::get_smt2(smt2_dect::solvert solver)
268268
if(options.get_bool_option("fpa"))
269269
smt2_dec->use_FPA_theory = true;
270270

271+
smt2_dec->set_message_handler(message_handler);
272+
271273
set_prop_conv_time_limit(*smt2_dec);
272274
return util_make_unique<solvert>(std::move(smt2_dec));
273275
}
@@ -284,8 +286,6 @@ solver_factoryt::get_smt2(smt2_dect::solvert solver)
284286
if(options.get_bool_option("fpa"))
285287
smt2_conv->use_FPA_theory = true;
286288

287-
smt2_conv->set_message_handler(message_handler);
288-
289289
set_prop_conv_time_limit(*smt2_conv);
290290
return util_make_unique<solvert>(std::move(smt2_conv));
291291
}
@@ -314,8 +314,6 @@ solver_factoryt::get_smt2(smt2_dect::solvert solver)
314314
if(options.get_bool_option("fpa"))
315315
smt2_conv->use_FPA_theory = true;
316316

317-
smt2_conv->set_message_handler(message_handler);
318-
319317
set_prop_conv_time_limit(*smt2_conv);
320318
return util_make_unique<solvert>(std::move(smt2_conv), std::move(out));
321319
}

src/goto-instrument/accelerate/scratch_program.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class scratch_programt:public goto_programt
4141
symbol_table(_symbol_table),
4242
symex_symbol_table(),
4343
ns(symbol_table, symex_symbol_table),
44-
equation(),
44+
equation(mh),
4545
path_storage(),
4646
options(get_default_options()),
4747
symex(mh, symbol_table, equation, options, path_storage),

src/goto-symex/symex_target_equation.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,10 @@ void symex_target_equationt::convert_assignments(
357357
{
358358
if(step.is_assignment() && !step.ignore && !step.converted)
359359
{
360-
decision_procedure.conditional_output(
361-
decision_procedure.debug(),
362-
[&step](messaget::mstreamt &mstream) {
363-
step.output(mstream);
364-
mstream << messaget::eom;
365-
});
360+
log.conditional_output(log.debug(), [&step](messaget::mstreamt &mstream) {
361+
step.output(mstream);
362+
mstream << messaget::eom;
363+
});
366364

367365
decision_procedure.set_to_true(step.cond_expr);
368366
step.converted = true;
@@ -402,12 +400,10 @@ void symex_target_equationt::convert_guards(
402400
step.guard_literal=const_literal(false);
403401
else
404402
{
405-
prop_conv.conditional_output(
406-
prop_conv.debug(),
407-
[&step](messaget::mstreamt &mstream) {
408-
step.output(mstream);
409-
mstream << messaget::eom;
410-
});
403+
log.conditional_output(log.debug(), [&step](messaget::mstreamt &mstream) {
404+
step.output(mstream);
405+
mstream << messaget::eom;
406+
});
411407

412408
try
413409
{
@@ -434,9 +430,8 @@ void symex_target_equationt::convert_assumptions(
434430
step.cond_literal=const_literal(true);
435431
else
436432
{
437-
prop_conv.conditional_output(
438-
prop_conv.debug(),
439-
[&step](messaget::mstreamt &mstream) {
433+
log.conditional_output(
434+
log.debug(), [&step](messaget::mstreamt &mstream) {
440435
step.output(mstream);
441436
mstream << messaget::eom;
442437
});
@@ -467,9 +462,8 @@ void symex_target_equationt::convert_goto_instructions(
467462
step.cond_literal=const_literal(true);
468463
else
469464
{
470-
prop_conv.conditional_output(
471-
prop_conv.debug(),
472-
[&step](messaget::mstreamt &mstream) {
465+
log.conditional_output(
466+
log.debug(), [&step](messaget::mstreamt &mstream) {
473467
step.output(mstream);
474468
mstream << messaget::eom;
475469
});
@@ -496,8 +490,8 @@ void symex_target_equationt::convert_constraints(
496490
{
497491
if(step.is_constraint() && !step.ignore && !step.converted)
498492
{
499-
decision_procedure.conditional_output(
500-
decision_procedure.debug(), [&step](messaget::mstreamt &mstream) {
493+
log.conditional_output(
494+
log.debug(), [&step](messaget::mstreamt &mstream) {
501495
step.output(mstream);
502496
mstream << messaget::eom;
503497
});
@@ -566,8 +560,8 @@ void symex_target_equationt::convert_assertions(
566560
{
567561
step.converted = true;
568562

569-
prop_conv.conditional_output(
570-
prop_conv.debug(),
563+
log.conditional_output(
564+
log.debug(),
571565
[&step](messaget::mstreamt &mstream) {
572566
step.output(mstream);
573567
mstream << messaget::eom;

src/goto-symex/symex_target_equation.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening, kroening@kroening.com
1818

1919
#include <util/invariant.h>
2020
#include <util/merge_irep.h>
21+
#include <util/message.h>
2122
#include <util/narrow.h>
2223

2324
#include <goto-programs/goto_program.h>
@@ -37,6 +38,11 @@ class prop_convt;
3738
class symex_target_equationt:public symex_targett
3839
{
3940
public:
41+
symex_target_equationt(message_handlert &message_handler)
42+
: log(message_handler)
43+
{
44+
}
45+
4046
virtual ~symex_target_equationt() = default;
4147

4248
/// \copydoc symex_targett::shared_read()
@@ -405,6 +411,8 @@ class symex_target_equationt:public symex_targett
405411
}
406412

407413
protected:
414+
messaget log;
415+
408416
// for enforcing sharing in the expressions stored
409417
merge_irept merge_irep;
410418
void merge_ireps(SSA_stept &SSA_step);

src/solvers/prop/prop_conv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening, kroening@kroening.com
1515

1616
#include <util/decision_procedure.h>
1717
#include <util/expr.h>
18+
#include <util/message.h>
1819
#include <util/std_expr.h>
1920

2021
#include "literal.h"
@@ -64,7 +65,7 @@ class prop_convt:public decision_proceduret
6465

6566
/*! \brief TO_BE_DOCUMENTED
6667
*/
67-
class prop_conv_solvert:public prop_convt
68+
class prop_conv_solvert : public prop_convt, public messaget
6869
{
6970
public:
7071
explicit prop_conv_solvert(propt &_prop) : prop(_prop)

src/solvers/smt2/smt2_dec.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class smt2_stringstreamt
2222

2323
/*! \brief Decision procedure interface for various SMT 2.x solvers
2424
*/
25-
class smt2_dect:protected smt2_stringstreamt, public smt2_convt
25+
class smt2_dect : protected smt2_stringstreamt,
26+
public smt2_convt,
27+
public messaget
2628
{
2729
public:
2830
smt2_dect(

src/util/decision_procedure.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ Author: Daniel Kroening, kroening@kroening.com
1212
#ifndef CPROVER_UTIL_DECISION_PROCEDURE_H
1313
#define CPROVER_UTIL_DECISION_PROCEDURE_H
1414

15-
#include "message.h"
15+
#include <iosfwd>
16+
#include <string>
1617

1718
class exprt;
1819

19-
class decision_proceduret:public messaget
20+
class decision_proceduret
2021
{
2122
public:
2223
virtual ~decision_proceduret();

unit/goto-symex/ssa_equation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Author: Diffblue Ltd.
66
77
\*******************************************************************/
88

9+
#include <testing-utils/message.h>
910
#include <testing-utils/use_catch.h>
1011

1112
#include <util/arith_tools.h>
@@ -25,7 +26,7 @@ SCENARIO("Validation of well-formed SSA steps", "[core][goto-symex][validate]")
2526
fun_symbol.name = fun_name;
2627
symbol_exprt fun_foo(fun_name, code_type);
2728

28-
symex_target_equationt equation;
29+
symex_target_equationt equation(null_message_handler);
2930
symex_targett::sourcet empty_source;
3031
equation.SSA_steps.emplace_back(
3132
empty_source, goto_trace_stept::typet::FUNCTION_RETURN);

0 commit comments

Comments
 (0)