Skip to content

Commit bf24482

Browse files
Group symex options into symex_config structure
This makes it easy to separate the constant parameters of that class from the other fields.
1 parent 10edd29 commit bf24482

7 files changed

+48
-35
lines changed

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(simplify_opt)
21+
if(symex_config.simplify_opt)
2222
simplify(expr, ns);
2323
}
2424

src/goto-symex/goto_symex.h

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ class namespacet;
3838
class side_effect_exprt;
3939
class typecast_exprt;
4040

41+
/// Configuration of the symbolic execution
42+
struct symex_configt final
43+
{
44+
unsigned max_depth;
45+
bool doing_path_exploration;
46+
bool allow_pointer_unsoundness;
47+
bool constant_propagation;
48+
bool self_loops_to_assumptions;
49+
bool simplify_opt;
50+
bool unwinding_assertions;
51+
bool partial_loops;
52+
std::string debug_level;
53+
54+
explicit symex_configt(const optionst &options);
55+
};
56+
4157
/// \brief The main class for the forward symbolic simulator
4258
///
4359
/// Higher-level architectural information on symbolic execution is
@@ -55,18 +71,8 @@ class goto_symext
5571
const optionst &options,
5672
path_storaget &path_storage)
5773
: should_pause_symex(false),
58-
max_depth(options.get_unsigned_int_option("depth")),
59-
doing_path_exploration(options.is_set("paths")),
60-
allow_pointer_unsoundness(
61-
options.get_bool_option("allow-pointer-unsoundness")),
74+
symex_config(options),
6275
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")),
7076
outer_symbol_table(outer_symbol_table),
7177
ns(outer_symbol_table),
7278
target(_target),
@@ -140,6 +146,8 @@ class goto_symext
140146
bool should_pause_symex;
141147

142148
protected:
149+
const symex_configt symex_config;
150+
143151
/// Initialise the symbolic execution and the given state with <code>pc</code>
144152
/// as entry point.
145153
/// \param state Symex state to initialise.
@@ -166,23 +174,13 @@ class goto_symext
166174
const get_goto_functiont &,
167175
statet &);
168176

169-
const unsigned max_depth;
170-
const bool doing_path_exploration;
171-
const bool allow_pointer_unsoundness;
172-
173177
public:
174178

175179
/// language_mode: ID_java, ID_C or another language identifier
176180
/// if we know the source language in use, irep_idt() otherwise.
177181
irep_idt language_mode;
178182

179183
protected:
180-
const bool constant_propagation;
181-
const bool self_loops_to_assumptions;
182-
const bool simplify_opt;
183-
const bool unwinding_assertions;
184-
const bool partial_loops;
185-
const std::string debug_level;
186184

187185
/// The symbol table associated with the goto-program that we're
188186
/// executing. This symbol table will not additionally contain objects

src/goto-symex/symex_assign.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ void goto_symext::symex_assign_symbol(
247247
ssa_lhs,
248248
ssa_rhs,
249249
ns,
250-
simplify_opt,
251-
constant_propagation,
252-
allow_pointer_unsoundness);
250+
symex_config.simplify_opt,
251+
symex_config.constant_propagation,
252+
symex_config.allow_pointer_unsoundness);
253253

254254
exprt ssa_full_lhs=full_lhs;
255255
ssa_full_lhs=add_to_lhs(ssa_full_lhs, ssa_lhs);

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(debug_level);
461+
int debug_thresh = unsafe_string2int(symex_config.debug_level);
462462

463463
mp_integer debug_lvl;
464464
optionalt<mp_integer> maybe_debug =

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(partial_loops)
239+
if(symex_config.partial_loops)
240240
{
241241
// it's ok, ignore
242242
}
243243
else
244244
{
245-
if(unwinding_assertions)
245+
if(symex_config.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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void goto_symext::symex_goto(statet &state)
6161
{
6262
// is it label: goto label; or while(cond); - popular in SV-COMP
6363
if(
64-
self_loops_to_assumptions &&
64+
symex_config.self_loops_to_assumptions &&
6565
(goto_target == state.source.pc ||
6666
(instruction.incoming_edges.size() == 1 &&
6767
*instruction.incoming_edges.begin() == goto_target)))
@@ -109,7 +109,7 @@ void goto_symext::symex_goto(statet &state)
109109
(simpl_state_guard.is_true() ||
110110
// or there is another block, but we're doing path exploration so
111111
// we're going to skip over it for now and return to it later.
112-
doing_path_exploration))
112+
symex_config.doing_path_exploration))
113113
{
114114
DATA_INVARIANT(
115115
instruction.targets.size() > 0,
@@ -176,7 +176,7 @@ void goto_symext::symex_goto(statet &state)
176176
log.debug() << "Resuming from next instruction '"
177177
<< state_pc->source_location << "'" << log.eom;
178178
}
179-
else if(doing_path_exploration)
179+
else if(symex_config.doing_path_exploration)
180180
{
181181
// We should save both the instruction after this goto, and the target of
182182
// the goto.
@@ -494,9 +494,9 @@ void goto_symext::loop_bound_exceeded(
494494
else
495495
negated_cond=not_exprt(guard);
496496

497-
if(!partial_loops)
497+
if(!symex_config.partial_loops)
498498
{
499-
if(unwinding_assertions)
499+
if(symex_config.unwinding_assertions)
500500
{
501501
// Generate VCC for unwinding assertion.
502502
vcc(negated_cond,

src/goto-symex/symex_main.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ Author: Daniel Kroening, [email protected]
2222

2323
#include <analyses/dirty.h>
2424

25+
symex_configt::symex_configt(const optionst &options)
26+
: max_depth(options.get_unsigned_int_option("depth")),
27+
doing_path_exploration(options.is_set("paths")),
28+
allow_pointer_unsoundness(
29+
options.get_bool_option("allow-pointer-unsoundness")),
30+
constant_propagation(options.get_bool_option("propagation")),
31+
self_loops_to_assumptions(
32+
options.get_bool_option("self-loops-to-assumptions")),
33+
simplify_opt(options.get_bool_option("simplify")),
34+
unwinding_assertions(options.get_bool_option("unwinding-assertions")),
35+
partial_loops(options.get_bool_option("partial-loops")),
36+
debug_level(options.get_option("debug-level"))
37+
{
38+
}
39+
2540
void goto_symext::symex_transition(
2641
statet &state,
2742
goto_programt::const_targett to,
@@ -292,11 +307,11 @@ void goto_symext::symex_step(
292307

293308
const goto_programt::instructiont &instruction=*state.source.pc;
294309

295-
if(!doing_path_exploration)
310+
if(!symex_config.doing_path_exploration)
296311
merge_gotos(state);
297312

298313
// depth exceeded?
299-
if(max_depth != 0 && state.depth > max_depth)
314+
if(symex_config.max_depth != 0 && state.depth > symex_config.max_depth)
300315
state.guard.add(false_exprt());
301316
state.depth++;
302317

0 commit comments

Comments
 (0)