Skip to content

Commit 038ed78

Browse files
authored
Merge pull request diffblue#1625 from karkhaz/kk-symext-is-messaget
Make goto_symext a subtype of messaget
2 parents b9372f1 + 6c6f873 commit 038ed78

19 files changed

+231
-182
lines changed

src/cbmc/bmc.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ void bmct::get_memory_model()
340340
void bmct::setup()
341341
{
342342
get_memory_model();
343-
symex.set_message_handler(get_message_handler());
344343
symex.options=options;
345344

346345
{

src/cbmc/bmc.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ class bmct:public safety_checkert
3838
const optionst &_options,
3939
const symbol_tablet &_symbol_table,
4040
message_handlert &_message_handler,
41-
prop_convt &_prop_conv):
42-
safety_checkert(ns, _message_handler),
43-
options(_options),
44-
ns(_symbol_table, new_symbol_table),
45-
equation(ns),
46-
symex(ns, new_symbol_table, equation),
47-
prop_conv(_prop_conv),
48-
ui(ui_message_handlert::uit::PLAIN)
41+
prop_convt &_prop_conv)
42+
: safety_checkert(ns, _message_handler),
43+
options(_options),
44+
ns(_symbol_table, new_symbol_table),
45+
equation(ns),
46+
symex(_message_handler, ns, new_symbol_table, equation),
47+
prop_conv(_prop_conv),
48+
ui(ui_message_handlert::uit::PLAIN)
4949
{
5050
symex.constant_propagation=options.get_bool_option("propagation");
5151
symex.record_coverage=

src/cbmc/symex_bmc.cpp

+27-30
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ Author: Daniel Kroening, [email protected]
1717
#include <util/simplify_expr.h>
1818

1919
symex_bmct::symex_bmct(
20+
message_handlert &mh,
2021
const namespacet &_ns,
2122
symbol_tablet &_new_symbol_table,
22-
symex_targett &_target):
23-
goto_symext(_ns, _new_symbol_table, _target),
24-
record_coverage(false),
25-
max_unwind(0),
26-
max_unwind_is_set(false),
27-
symex_coverage(_ns)
23+
symex_targett &_target)
24+
: goto_symext(mh, _ns, _new_symbol_table, _target),
25+
record_coverage(false),
26+
max_unwind(0),
27+
max_unwind_is_set(false),
28+
symex_coverage(_ns)
2829
{
2930
}
3031

@@ -37,10 +38,9 @@ void symex_bmct::symex_step(
3738

3839
if(!source_location.is_nil() && last_source_location!=source_location)
3940
{
40-
debug() << "BMC at file " << source_location.get_file()
41-
<< " line " << source_location.get_line()
42-
<< " function " << source_location.get_function()
43-
<< eom;
41+
log.debug() << "BMC at file " << source_location.get_file() << " line "
42+
<< source_location.get_line() << " function "
43+
<< source_location.get_function() << log.eom;
4444

4545
last_source_location=source_location;
4646
}
@@ -52,15 +52,15 @@ void symex_bmct::symex_step(
5252
state.source.pc->is_assume() &&
5353
simplify_expr(state.source.pc->guard, ns).is_false())
5454
{
55-
statistics() << "aborting path on assume(false) at "
56-
<< state.source.pc->source_location
57-
<< " thread " << state.source.thread_nr;
55+
log.statistics() << "aborting path on assume(false) at "
56+
<< state.source.pc->source_location << " thread "
57+
<< state.source.thread_nr;
5858

5959
const irep_idt &c=state.source.pc->source_location.get_comment();
6060
if(!c.empty())
61-
statistics() << ": " << c;
61+
log.statistics() << ": " << c;
6262

63-
statistics() << eom;
63+
log.statistics() << log.eom;
6464
}
6565

6666
goto_symext::symex_step(goto_functions, state);
@@ -94,7 +94,7 @@ void symex_bmct::merge_goto(
9494

9595
goto_symext::merge_goto(goto_state, state);
9696

97-
assert(prev_pc->is_goto());
97+
PRECONDITION(prev_pc->is_goto());
9898
if(record_coverage &&
9999
// could the branch possibly be taken?
100100
!prev_guard.is_false() &&
@@ -132,15 +132,14 @@ bool symex_bmct::get_unwind(
132132

133133
bool abort=unwind>=this_loop_limit;
134134

135-
statistics() << (abort?"Not unwinding":"Unwinding")
136-
<< " loop " << id << " iteration "
137-
<< unwind;
135+
log.statistics() << (abort ? "Not unwinding" : "Unwinding") << " loop " << id
136+
<< " iteration " << unwind;
138137

139138
if(this_loop_limit!=std::numeric_limits<unsigned>::max())
140-
statistics() << " (" << this_loop_limit << " max)";
139+
log.statistics() << " (" << this_loop_limit << " max)";
141140

142-
statistics() << " " << source.pc->source_location
143-
<< " thread " << source.thread_nr << eom;
141+
log.statistics() << " " << source.pc->source_location << " thread "
142+
<< source.thread_nr << log.eom;
144143

145144
return abort;
146145
}
@@ -176,15 +175,13 @@ bool symex_bmct::get_unwind_recursion(
176175
{
177176
const symbolt &symbol=ns.lookup(id);
178177

179-
statistics() << (abort?"Not unwinding":"Unwinding")
180-
<< " recursion "
181-
<< symbol.display_name()
182-
<< " iteration " << unwind;
178+
log.statistics() << (abort ? "Not unwinding" : "Unwinding") << " recursion "
179+
<< symbol.display_name() << " iteration " << unwind;
183180

184181
if(this_loop_limit!=std::numeric_limits<unsigned>::max())
185-
statistics() << " (" << this_loop_limit << " max)";
182+
log.statistics() << " (" << this_loop_limit << " max)";
186183

187-
statistics() << eom;
184+
log.statistics() << log.eom;
188185
}
189186

190187
return abort;
@@ -194,7 +191,7 @@ void symex_bmct::no_body(const irep_idt &identifier)
194191
{
195192
if(body_warnings.insert(identifier).second)
196193
{
197-
warning() <<
198-
"**** WARNING: no body for function " << identifier << eom;
194+
log.warning() << "**** WARNING: no body for function " << identifier
195+
<< log.eom;
199196
}
200197
}

src/cbmc/symex_bmc.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ Author: Daniel Kroening, [email protected]
1818

1919
#include "symex_coverage.h"
2020

21-
class symex_bmct:
22-
public goto_symext,
23-
public messaget
21+
class symex_bmct: public goto_symext
2422
{
2523
public:
2624
symex_bmct(
25+
message_handlert &mh,
2726
const namespacet &_ns,
2827
symbol_tablet &_new_symbol_table,
2928
symex_targett &_target);

src/goto-instrument/accelerate/accelerate.cpp

+13-12
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ int acceleratet::accelerate_loop(goto_programt::targett &loop_header)
109109
program.update();
110110

111111
#if 1
112-
enumerating_loop_accelerationt
113-
acceleration(
114-
symbol_table,
115-
goto_functions,
116-
program,
117-
loop,
118-
loop_header,
119-
accelerate_limit);
112+
enumerating_loop_accelerationt acceleration(
113+
message_handler,
114+
symbol_table,
115+
goto_functions,
116+
program,
117+
loop,
118+
loop_header,
119+
accelerate_limit);
120120
#else
121121
disjunctive_polynomial_accelerationt
122122
acceleration(symbol_table, goto_functions, program, loop, loop_header);
@@ -333,7 +333,7 @@ void acceleratet::set_dirty_vars(path_acceleratort &accelerator)
333333

334334
if(jt==dirty_vars_map.end())
335335
{
336-
scratch_programt scratch(symbol_table);
336+
scratch_programt scratch(symbol_table, message_handler);
337337
symbolt new_sym=utils.fresh_symbol("accelerate::dirty", bool_typet());
338338
dirty_var=new_sym.symbol_expr();
339339
dirty_vars_map[*it]=dirty_var;
@@ -512,7 +512,7 @@ void acceleratet::insert_automaton(trace_automatont &automaton)
512512
// machine.
513513
for(const auto &sym : automaton.alphabet)
514514
{
515-
scratch_programt state_machine(symbol_table);
515+
scratch_programt state_machine(symbol_table, message_handler);
516516
trace_automatont::sym_range_pairt p=transitions.equal_range(sym);
517517

518518
build_state_machine(p.first, p.second, accept_states, state, next_state,
@@ -648,15 +648,16 @@ int acceleratet::accelerate_loops()
648648
return num_accelerated;
649649
}
650650

651-
652651
void accelerate_functions(
653652
goto_modelt &goto_model,
653+
message_handlert &message_handler,
654654
bool use_z3)
655655
{
656656
Forall_goto_functions(it, goto_model.goto_functions)
657657
{
658658
std::cout << "Accelerating function " << it->first << '\n';
659-
acceleratet accelerate(it->second.body, goto_model, use_z3);
659+
acceleratet accelerate(
660+
it->second.body, goto_model, message_handler, use_z3);
660661

661662
int num_accelerated=accelerate.accelerate_loops();
662663

src/goto-instrument/accelerate/accelerate.h

+47-34
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Matt Lewis
1414

1515
#include <util/namespace.h>
1616
#include <util/expr.h>
17+
#include <util/message.h>
1718

1819
#include <analyses/natural_loops.h>
1920

@@ -28,15 +29,18 @@ Author: Matt Lewis
2829

2930
class acceleratet
3031
{
31-
public:
32-
acceleratet(goto_programt &_program,
33-
goto_modelt &_goto_model,
34-
bool _use_z3):
32+
public:
33+
acceleratet(
34+
goto_programt &_program,
35+
goto_modelt &_goto_model,
36+
message_handlert &message_handler,
37+
bool _use_z3)
38+
: message_handler(message_handler),
3539
program(_program),
3640
goto_functions(_goto_model.goto_functions),
3741
symbol_table(_goto_model.symbol_table),
3842
ns(_goto_model.symbol_table),
39-
utils(symbol_table, goto_functions),
43+
utils(symbol_table, message_handler, goto_functions),
4044
use_z3(_use_z3)
4145
{
4246
natural_loops(program);
@@ -51,46 +55,54 @@ class acceleratet
5155

5256
static const int accelerate_limit = -1;
5357

54-
protected:
55-
void find_paths(goto_programt::targett &loop_header,
56-
pathst &loop_paths,
57-
pathst &exit_paths,
58-
goto_programt::targett &back_jump);
58+
protected:
59+
message_handlert &message_handler;
5960

60-
void extend_path(goto_programt::targett &t,
61-
goto_programt::targett &loop_header,
62-
natural_loops_mutablet::natural_loopt &loop,
63-
patht &prefix,
64-
pathst &loop_paths,
65-
pathst &exit_paths,
66-
goto_programt::targett &back_jump);
61+
void find_paths(
62+
goto_programt::targett &loop_header,
63+
pathst &loop_paths,
64+
pathst &exit_paths,
65+
goto_programt::targett &back_jump);
66+
67+
void extend_path(
68+
goto_programt::targett &t,
69+
goto_programt::targett &loop_header,
70+
natural_loops_mutablet::natural_loopt &loop,
71+
patht &prefix,
72+
pathst &loop_paths,
73+
pathst &exit_paths,
74+
goto_programt::targett &back_jump);
6775

6876
goto_programt::targett find_back_jump(goto_programt::targett loop_header);
6977

70-
void insert_looping_path(goto_programt::targett &loop_header,
71-
goto_programt::targett &back_jump,
72-
goto_programt &looping_path,
73-
patht &inserted_path);
74-
void insert_accelerator(goto_programt::targett &loop_header,
75-
goto_programt::targett &back_jump,
76-
path_acceleratort &accelerator,
77-
subsumed_patht &subsumed);
78+
void insert_looping_path(
79+
goto_programt::targett &loop_header,
80+
goto_programt::targett &back_jump,
81+
goto_programt &looping_path,
82+
patht &inserted_path);
83+
void insert_accelerator(
84+
goto_programt::targett &loop_header,
85+
goto_programt::targett &back_jump,
86+
path_acceleratort &accelerator,
87+
subsumed_patht &subsumed);
7888

7989
void set_dirty_vars(path_acceleratort &accelerator);
8090
void add_dirty_checks();
8191
bool is_underapproximate(path_acceleratort &accelerator);
8292

83-
void make_overflow_loc(goto_programt::targett loop_header,
84-
goto_programt::targett &loop_end,
85-
goto_programt::targett &overflow_loc);
93+
void make_overflow_loc(
94+
goto_programt::targett loop_header,
95+
goto_programt::targett &loop_end,
96+
goto_programt::targett &overflow_loc);
8697

8798
void insert_automaton(trace_automatont &automaton);
88-
void build_state_machine(trace_automatont::sym_mapt::iterator p,
89-
trace_automatont::sym_mapt::iterator end,
90-
state_sett &accept_states,
91-
symbol_exprt state,
92-
symbol_exprt next_state,
93-
scratch_programt &state_machine);
99+
void build_state_machine(
100+
trace_automatont::sym_mapt::iterator p,
101+
trace_automatont::sym_mapt::iterator end,
102+
state_sett &accept_states,
103+
symbol_exprt state,
104+
symbol_exprt next_state,
105+
scratch_programt &state_machine);
94106

95107
symbolt make_symbol(std::string name, typet type);
96108
void decl(symbol_exprt &sym, goto_programt::targett t);
@@ -117,6 +129,7 @@ class acceleratet
117129

118130
void accelerate_functions(
119131
goto_modelt &,
132+
message_handlert &message_handler,
120133
bool use_z3);
121134

122135
#endif // CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATE_H

src/goto-instrument/accelerate/acceleration_utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool acceleration_utilst::check_inductive(
128128
// assert (target1==polynomial1);
129129
// assert (target2==polynomial2);
130130
// ...
131-
scratch_programt program(symbol_table);
131+
scratch_programt program(symbol_table, message_handler);
132132
std::vector<exprt> polynomials_hold;
133133
substitutiont substitution;
134134

@@ -386,7 +386,7 @@ bool acceleration_utilst::do_assumptions(
386386
// assert(!precondition);
387387

388388
exprt condition=precondition(path);
389-
scratch_programt program(symbol_table);
389+
scratch_programt program(symbol_table, message_handler);
390390

391391
substitutiont substitution;
392392
stash_polynomials(program, polynomials, substitution, path);

0 commit comments

Comments
 (0)