Skip to content

Commit ab09a6c

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 24295fa commit ab09a6c

File tree

14 files changed

+45
-48
lines changed

14 files changed

+45
-48
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
@@ -45,8 +45,6 @@ decision_proceduret::resultt bmct::run_decision_procedure()
4545
status() << "Passing problem to "
4646
<< prop_conv.decision_procedure_text() << eom;
4747

48-
prop_conv.set_message_handler(get_message_handler());
49-
5048
auto solver_start = std::chrono::steady_clock::now();
5149

5250
convert_symex_target_equation(equation, prop_conv, get_message_handler());
@@ -192,8 +190,6 @@ safety_checkert::resultt bmct::run(
192190

193191
safety_checkert::resultt bmct::decide(const goto_functionst &goto_functions)
194192
{
195-
prop_conv.set_message_handler(get_message_handler());
196-
197193
if(options.get_bool_option("stop-on-fail"))
198194
return stop_on_fail();
199195
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/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_checker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ operator()(propertiest &properties)
4949
symex_initialized = true;
5050

5151
// Put initial state into the work list
52-
symex_target_equationt equation;
52+
symex_target_equationt equation(ui_message_handler);
5353
symex_bmct symex(
5454
ui_message_handler,
5555
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: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,10 @@ void symex_target_equationt::convert_assignments(
359359
{
360360
if(step.is_assignment() && !step.ignore && !step.converted)
361361
{
362-
decision_procedure.conditional_output(
363-
decision_procedure.debug(),
364-
[&step](messaget::mstreamt &mstream) {
365-
step.output(mstream);
366-
mstream << messaget::eom;
367-
});
362+
log.conditional_output(log.debug(), [&step](messaget::mstreamt &mstream) {
363+
step.output(mstream);
364+
mstream << messaget::eom;
365+
});
368366

369367
decision_procedure.set_to_true(step.cond_expr);
370368
step.converted = true;
@@ -404,12 +402,10 @@ void symex_target_equationt::convert_guards(
404402
step.guard_literal=const_literal(false);
405403
else
406404
{
407-
prop_conv.conditional_output(
408-
prop_conv.debug(),
409-
[&step](messaget::mstreamt &mstream) {
410-
step.output(mstream);
411-
mstream << messaget::eom;
412-
});
405+
log.conditional_output(log.debug(), [&step](messaget::mstreamt &mstream) {
406+
step.output(mstream);
407+
mstream << messaget::eom;
408+
});
413409

414410
try
415411
{
@@ -436,9 +432,8 @@ void symex_target_equationt::convert_assumptions(
436432
step.cond_literal=const_literal(true);
437433
else
438434
{
439-
prop_conv.conditional_output(
440-
prop_conv.debug(),
441-
[&step](messaget::mstreamt &mstream) {
435+
log.conditional_output(
436+
log.debug(), [&step](messaget::mstreamt &mstream) {
442437
step.output(mstream);
443438
mstream << messaget::eom;
444439
});
@@ -469,9 +464,8 @@ void symex_target_equationt::convert_goto_instructions(
469464
step.cond_literal=const_literal(true);
470465
else
471466
{
472-
prop_conv.conditional_output(
473-
prop_conv.debug(),
474-
[&step](messaget::mstreamt &mstream) {
467+
log.conditional_output(
468+
log.debug(), [&step](messaget::mstreamt &mstream) {
475469
step.output(mstream);
476470
mstream << messaget::eom;
477471
});
@@ -498,11 +492,10 @@ void symex_target_equationt::convert_constraints(
498492
{
499493
if(step.is_constraint() && !step.ignore && !step.converted)
500494
{
501-
decision_procedure.conditional_output(
502-
decision_procedure.debug(), [&step](messaget::mstreamt &mstream) {
503-
step.output(mstream);
504-
mstream << messaget::eom;
505-
});
495+
log.conditional_output(log.debug(), [&step](messaget::mstreamt &mstream) {
496+
step.output(mstream);
497+
mstream << messaget::eom;
498+
});
506499

507500
try
508501
{
@@ -568,12 +561,10 @@ void symex_target_equationt::convert_assertions(
568561
{
569562
step.converted = true;
570563

571-
prop_conv.conditional_output(
572-
prop_conv.debug(),
573-
[&step](messaget::mstreamt &mstream) {
574-
step.output(mstream);
575-
mstream << messaget::eom;
576-
});
564+
log.conditional_output(log.debug(), [&step](messaget::mstreamt &mstream) {
565+
step.output(mstream);
566+
mstream << messaget::eom;
567+
});
577568

578569
implies_exprt implication(
579570
assumption,

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, [email protected]
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+
explicit 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()
@@ -408,6 +414,8 @@ class symex_target_equationt:public symex_targett
408414
}
409415

410416
protected:
417+
messaget log;
418+
411419
// for enforcing sharing in the expressions stored
412420
merge_irept merge_irep;
413421
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, [email protected]
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"
@@ -67,7 +68,7 @@ class prop_convt:public decision_proceduret
6768

6869
/*! \brief TO_BE_DOCUMENTED
6970
*/
70-
class prop_conv_solvert:public prop_convt
71+
class prop_conv_solvert : public prop_convt, public messaget
7172
{
7273
public:
7374
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, [email protected]
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>
@@ -27,7 +28,7 @@ SCENARIO("Validation of well-formed SSA steps", "[core][goto-symex][validate]")
2728

2829
goto_programt goto_program;
2930
goto_program.add_instruction(END_FUNCTION);
30-
symex_target_equationt equation;
31+
symex_target_equationt equation(null_message_handler);
3132
symex_targett::sourcet at_end_function(fun_name, goto_program);
3233
equation.SSA_steps.emplace_back(
3334
at_end_function, goto_trace_stept::typet::FUNCTION_RETURN);

0 commit comments

Comments
 (0)