Skip to content

Commit 51236f2

Browse files
authored
Merge pull request #3221 from karkhaz/kk-goto-symex-member-cleanup
goto symex member cleanup
2 parents 0b81f16 + 622940c commit 51236f2

14 files changed

+38
-48
lines changed

src/cbmc/bmc.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ class bmct:public safety_checkert
8686
ui_message_handler(_message_handler),
8787
driver_callback_after_symex(callback_after_symex)
8888
{
89-
symex.constant_propagation=options.get_bool_option("propagation");
90-
symex.record_coverage=
91-
!options.get_option("symex-coverage-report").empty();
92-
symex.self_loops_to_assumptions =
93-
options.get_bool_option("self-loops-to-assumptions");
9489
}
9590

9691
virtual resultt run(const goto_functionst &goto_functions)
@@ -162,9 +157,6 @@ class bmct:public safety_checkert
162157
ui_message_handler(_message_handler),
163158
driver_callback_after_symex(callback_after_symex)
164159
{
165-
symex.constant_propagation = options.get_bool_option("propagation");
166-
symex.record_coverage =
167-
!options.get_option("symex-coverage-report").empty();
168160
INVARIANT(
169161
options.get_bool_option("paths"),
170162
"Should only use saved equation & goto_state constructor "

src/cbmc/symex_bmc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ symex_bmct::symex_bmct(
2525
const optionst &options,
2626
path_storaget &path_storage)
2727
: goto_symext(mh, outer_symbol_table, _target, options, path_storage),
28-
record_coverage(false),
28+
record_coverage(!options.get_option("symex-coverage-report").empty()),
2929
symex_coverage(ns)
3030
{
3131
}

src/cbmc/symex_bmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class symex_bmct: public goto_symext
8080
return symex_coverage.generate_report(goto_functions, path);
8181
}
8282

83-
bool record_coverage;
83+
const bool record_coverage;
8484

8585
unwindsett unwindset;
8686

src/goto-instrument/accelerate/scratch_program.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ bool scratch_programt::check_sat(bool do_slice)
3535
output(ns, "scratch", std::cout);
3636
#endif
3737

38-
symex.constant_propagation=constant_propagation;
3938
goto_symex_statet::propagationt::valuest constants;
4039

4140
symex.symex_with_state(symex_state, functions, symex_symbol_table);
@@ -203,3 +202,10 @@ void scratch_programt::append_loop(
203202
}
204203
}
205204
}
205+
206+
optionst scratch_programt::get_default_options()
207+
{
208+
optionst ret;
209+
ret.set_option("simplify", true);
210+
return ret;
211+
}

src/goto-instrument/accelerate/scratch_program.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,13 @@ class scratch_programt:public goto_programt
4343
ns(symbol_table, symex_symbol_table),
4444
equation(),
4545
path_storage(),
46-
options(),
46+
options(get_default_options()),
4747
symex(mh, symbol_table, equation, options, path_storage),
4848
satcheck(util_make_unique<satcheckt>()),
4949
satchecker(ns, *satcheck),
5050
z3(ns, "accelerate", "", "", smt2_dect::solvert::Z3),
5151
checker(&z3) // checker(&satchecker)
5252
{
53-
// Unconditionally set for performance reasons. This option setting applies
54-
// only to this program.
55-
options.set_option("simplify", true);
5653
}
5754

5855
void append(goto_programt::instructionst &instructions);
@@ -91,6 +88,7 @@ class scratch_programt:public goto_programt
9188
bv_pointerst satchecker;
9289
smt2_dect z3;
9390
prop_convt *checker;
91+
static optionst get_default_options();
9492
};
9593

9694
#endif // CPROVER_GOTO_INSTRUMENT_ACCELERATE_SCRATCH_PROGRAM_H

src/goto-symex/goto_symex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ unsigned goto_symext::dynamic_counter=0;
1818

1919
void goto_symext::do_simplify(exprt &expr)
2020
{
21-
if(options.get_bool_option("simplify"))
21+
if(simplify_opt)
2222
simplify(expr, ns);
2323
}
2424

src/goto-symex/goto_symex.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,18 @@ class goto_symext
5555
const optionst &options,
5656
path_storaget &path_storage)
5757
: should_pause_symex(false),
58-
options(options),
5958
max_depth(options.get_unsigned_int_option("depth")),
6059
doing_path_exploration(options.is_set("paths")),
6160
allow_pointer_unsoundness(
6261
options.get_bool_option("allow-pointer-unsoundness")),
63-
constant_propagation(true),
64-
self_loops_to_assumptions(true),
6562
language_mode(),
63+
constant_propagation(options.get_bool_option("propagation")),
64+
self_loops_to_assumptions(
65+
options.get_bool_option("self-loops-to-assumptions")),
66+
simplify_opt(options.get_bool_option("simplify")),
67+
unwinding_assertions(options.get_bool_option("unwinding-assertions")),
68+
partial_loops(options.get_bool_option("partial-loops")),
69+
debug_level(options.get_option("debug-level")),
6670
outer_symbol_table(outer_symbol_table),
6771
ns(outer_symbol_table),
6872
target(_target),
@@ -200,8 +204,6 @@ class goto_symext
200204
const get_goto_functiont &,
201205
statet &);
202206

203-
const optionst &options;
204-
205207
const unsigned max_depth;
206208
const bool doing_path_exploration;
207209
const bool allow_pointer_unsoundness;
@@ -210,14 +212,18 @@ class goto_symext
210212
// these bypass the target maps
211213
virtual void symex_step_goto(statet &, bool taken);
212214

213-
bool constant_propagation;
214-
bool self_loops_to_assumptions;
215-
216215
/// language_mode: ID_java, ID_C or another language identifier
217216
/// if we know the source language in use, irep_idt() otherwise.
218217
irep_idt language_mode;
219218

220219
protected:
220+
const bool constant_propagation;
221+
const bool self_loops_to_assumptions;
222+
const bool simplify_opt;
223+
const bool unwinding_assertions;
224+
const bool partial_loops;
225+
const std::string debug_level;
226+
221227
/// The symbol table associated with the goto-program that we're
222228
/// executing. This symbol table will not additionally contain objects
223229
/// that are dynamically created as part of symbolic execution; the
@@ -274,7 +280,7 @@ class goto_symext
274280

275281
// guards
276282

277-
irep_idt guard_identifier;
283+
const irep_idt guard_identifier;
278284

279285
// symex
280286
virtual void symex_transition(

src/goto-symex/symex_assign.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void goto_symext::symex_assign_symbol(
247247
ssa_lhs,
248248
ssa_rhs,
249249
ns,
250-
options.get_bool_option("simplify"),
250+
simplify_opt,
251251
constant_propagation,
252252
allow_pointer_unsoundness);
253253

src/goto-symex/symex_builtin_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ void goto_symext::symex_trace(
458458
{
459459
PRECONDITION(code.arguments().size() >= 2);
460460

461-
int debug_thresh=unsafe_string2int(options.get_option("debug-level"));
461+
int debug_thresh = unsafe_string2int(debug_level);
462462

463463
mp_integer debug_lvl;
464464
optionalt<mp_integer> maybe_debug =

src/goto-symex/symex_dereference.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ void goto_symext::dereference_rec(
281281
value_set_dereferencet dereference(
282282
ns,
283283
state.symbol_table,
284-
options,
285284
symex_dereference_state,
286285
language_mode,
287286
expr_is_not_null);

src/goto-symex/symex_function_call.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ void goto_symext::symex_function_call_code(
236236
// see if it's too much
237237
if(stop_recursing)
238238
{
239-
if(options.get_bool_option("partial-loops"))
239+
if(partial_loops)
240240
{
241241
// it's ok, ignore
242242
}
243243
else
244244
{
245-
if(options.get_bool_option("unwinding-assertions"))
245+
if(unwinding_assertions)
246246
vcc(false_exprt(), "recursion unwinding assertion", state);
247247

248248
// add to state guard to prevent further assignments

src/goto-symex/symex_goto.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,6 @@ void goto_symext::loop_bound_exceeded(
515515
else
516516
negated_cond=not_exprt(guard);
517517

518-
bool unwinding_assertions=
519-
options.get_bool_option("unwinding-assertions");
520-
521-
bool partial_loops=
522-
options.get_bool_option("partial-loops");
523-
524518
if(!partial_loops)
525519
{
526520
if(unwinding_assertions)

src/pointer-analysis/goto_program_dereference.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class goto_program_dereferencet:protected dereference_callbackt
3030
const namespacet &_ns,
3131
symbol_tablet &_new_symbol_table,
3232
const optionst &_options,
33-
value_setst &_value_sets):
34-
options(_options),
35-
ns(_ns),
36-
value_sets(_value_sets),
37-
dereference(_ns, _new_symbol_table, _options, *this, ID_nil, false)
38-
{
39-
}
33+
value_setst &_value_sets)
34+
: options(_options),
35+
ns(_ns),
36+
value_sets(_value_sets),
37+
dereference(_ns, _new_symbol_table, *this, ID_nil, false)
38+
{
39+
}
4040

4141
void dereference_program(
4242
goto_programt &goto_program,

src/pointer-analysis/value_set_dereference.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ class value_set_dereferencet
3232
/*! \brief Constructor
3333
* \param _ns Namespace
3434
* \param _new_symbol_table A symbol_table to store new symbols in
35-
* \param _options Options, in particular whether pointer checks are
36-
to be performed
3735
* \param _dereference_callback Callback object for error reporting
3836
* \param _language_mode Mode for any new symbols created to represent
3937
a dereference failure
@@ -43,13 +41,11 @@ class value_set_dereferencet
4341
value_set_dereferencet(
4442
const namespacet &_ns,
4543
symbol_tablet &_new_symbol_table,
46-
const optionst &_options,
4744
dereference_callbackt &_dereference_callback,
4845
const irep_idt _language_mode,
4946
bool _exclude_null_derefs):
5047
ns(_ns),
5148
new_symbol_table(_new_symbol_table),
52-
options(_options),
5349
dereference_callback(_dereference_callback),
5450
language_mode(_language_mode),
5551
exclude_null_derefs(_exclude_null_derefs)
@@ -83,7 +79,6 @@ class value_set_dereferencet
8379
private:
8480
const namespacet &ns;
8581
symbol_tablet &new_symbol_table;
86-
const optionst &options;
8782
dereference_callbackt &dereference_callback;
8883
/// language_mode: ID_java, ID_C or another language identifier
8984
/// if we know the source language in use, irep_idt() otherwise.

0 commit comments

Comments
 (0)