Skip to content

Commit e5df371

Browse files
committed
unwindsett: goto_model is only needed for options processing
An `unwindsett` does not need an `abstract_goto_modelt` as part of its state.
1 parent 3c915eb commit e5df371

13 files changed

+42
-36
lines changed

src/goto-checker/bmc_util.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ get_memory_model(const optionst &options, const namespacet &ns)
178178
void setup_symex(
179179
symex_bmct &symex,
180180
const namespacet &ns,
181-
const optionst &options,
182181
ui_message_handlert &ui_message_handler)
183182
{
184183
messaget msg(ui_message_handler);
@@ -189,10 +188,6 @@ void setup_symex(
189188
msg.status() << "Starting Bounded Model Checking" << messaget::eom;
190189

191190
symex.last_source_location.make_nil();
192-
193-
symex.unwindset.parse_unwind(options.get_option("unwind"));
194-
symex.unwindset.parse_unwindset(
195-
options.get_list_option("unwindset"), ui_message_handler);
196191
}
197192

198193
void slice(

src/goto-checker/bmc_util.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ void output_graphml(
6868
std::unique_ptr<memory_model_baset>
6969
get_memory_model(const optionst &options, const namespacet &);
7070

71-
void setup_symex(
72-
symex_bmct &,
73-
const namespacet &,
74-
const optionst &,
75-
ui_message_handlert &);
71+
void setup_symex(symex_bmct &, const namespacet &, ui_message_handlert &);
7672

7773
void slice(
7874
symex_bmct &,

src/goto-checker/multi_path_symex_only_checker.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ multi_path_symex_only_checkert::multi_path_symex_only_checkert(
2727
goto_model(goto_model),
2828
ns(goto_model.get_symbol_table(), symex_symbol_table),
2929
equation(ui_message_handler),
30-
unwindset(goto_model),
3130
symex(
3231
ui_message_handler,
3332
goto_model.get_symbol_table(),
@@ -37,7 +36,10 @@ multi_path_symex_only_checkert::multi_path_symex_only_checkert(
3736
guard_manager,
3837
unwindset)
3938
{
40-
setup_symex(symex, ns, options, ui_message_handler);
39+
unwindset.parse_unwind(options.get_option("unwind"));
40+
unwindset.parse_unwindset(
41+
options.get_list_option("unwindset"), goto_model, ui_message_handler);
42+
setup_symex(symex, ns, ui_message_handler);
4143
}
4244

4345
incremental_goto_checkert::resultt multi_path_symex_only_checkert::

src/goto-checker/single_loop_incremental_symex_checker.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ single_loop_incremental_symex_checkert::single_loop_incremental_symex_checkert(
2828
goto_model(goto_model),
2929
ns(goto_model.get_symbol_table(), symex_symbol_table),
3030
equation(ui_message_handler),
31-
unwindset(goto_model),
3231
symex(
3332
ui_message_handler,
3433
goto_model.get_symbol_table(),
@@ -40,7 +39,10 @@ single_loop_incremental_symex_checkert::single_loop_incremental_symex_checkert(
4039
ui_message_handler.get_ui()),
4140
property_decider(options, ui_message_handler, equation, ns)
4241
{
43-
setup_symex(symex, ns, options, ui_message_handler);
42+
unwindset.parse_unwind(options.get_option("unwind"));
43+
unwindset.parse_unwindset(
44+
options.get_list_option("unwindset"), goto_model, ui_message_handler);
45+
setup_symex(symex, ns, ui_message_handler);
4446

4547
// Freeze all symbols if we are using a prop_conv_solvert
4648
prop_conv_solvert *prop_conv_solver = dynamic_cast<prop_conv_solvert *>(

src/goto-checker/single_path_symex_only_checker.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ single_path_symex_only_checkert::single_path_symex_only_checkert(
2929
goto_model(goto_model),
3030
ns(goto_model.get_symbol_table(), symex_symbol_table),
3131
worklist(get_path_strategy(options.get_option("exploration-strategy"))),
32-
symex_runtime(0),
33-
unwindset(goto_model)
32+
symex_runtime(0)
3433
{
34+
unwindset.parse_unwind(options.get_option("unwind"));
35+
unwindset.parse_unwindset(
36+
options.get_list_option("unwindset"), goto_model, ui_message_handler);
3537
}
3638

3739
incremental_goto_checkert::resultt single_path_symex_only_checkert::
@@ -152,7 +154,7 @@ void single_path_symex_only_checkert::equation_output(
152154

153155
void single_path_symex_only_checkert::setup_symex(symex_bmct &symex)
154156
{
155-
::setup_symex(symex, ns, options, ui_message_handler);
157+
::setup_symex(symex, ns, ui_message_handler);
156158
}
157159

158160
void single_path_symex_only_checkert::update_properties(

src/goto-checker/symex_bmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class symex_bmct : public goto_symext
8181

8282
const bool record_coverage;
8383

84+
protected:
8485
unwindsett &unwindset;
8586

86-
protected:
8787
/// Callbacks that may provide an unwind/do-not-unwind decision for a loop
8888
std::vector<loop_unwind_handlert> loop_unwind_handlers;
8989

src/goto-instrument/contracts/contracts.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,8 +1493,9 @@ void code_contractst::apply_loop_contracts(
14931493
// unwind all transformed loops twice.
14941494
if(loop_contract_config.unwind_transformed_loops)
14951495
{
1496-
unwindsett unwindset{goto_model};
1497-
unwindset.parse_unwindset(loop_names, log.get_message_handler());
1496+
unwindsett unwindset;
1497+
unwindset.parse_unwindset(
1498+
loop_names, goto_model, log.get_message_handler());
14981499
goto_unwindt goto_unwind;
14991500
goto_unwind(goto_model, unwindset, goto_unwindt::unwind_strategyt::ASSUME);
15001501
}

src/goto-instrument/contracts/dynamic-frames/dfcc_instrument.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,8 @@ void dfcc_instrumentt::apply_loop_contracts(
12081208
// If required, unwind all transformed loops to yield base and step cases
12091209
if(loop_contract_config.unwind_transformed_loops)
12101210
{
1211-
unwindsett unwindset{goto_model};
1212-
unwindset.parse_unwindset(to_unwind, log.get_message_handler());
1211+
unwindsett unwindset;
1212+
unwindset.parse_unwindset(to_unwind, goto_model, log.get_message_handler());
12131213
goto_unwindt goto_unwind;
12141214
goto_unwind(goto_model, unwindset, goto_unwindt::unwind_strategyt::ASSUME);
12151215
}

src/goto-instrument/contracts/dynamic-frames/dfcc_library.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ void dfcc_libraryt::specialize(const std::size_t contract_assigns_size)
439439
"dfcc_libraryt::specialize_functions can only be called once");
440440

441441
specialized = true;
442-
unwindsett unwindset{goto_model};
443442
std::list<std::string> loop_names;
444443

445444
for(const auto &entry : to_unwind)
@@ -452,7 +451,8 @@ void dfcc_libraryt::specialize(const std::size_t contract_assigns_size)
452451
const auto &str = stream.str();
453452
loop_names.push_back(str);
454453
}
455-
unwindset.parse_unwindset(loop_names, message_handler);
454+
unwindsett unwindset;
455+
unwindset.parse_unwindset(loop_names, goto_model, message_handler);
456456
goto_unwindt goto_unwind;
457457
goto_unwind(
458458
goto_model, unwindset, goto_unwindt::unwind_strategyt::ASSERT_ASSUME);

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,24 @@ int goto_instrument_parse_optionst::doit()
183183

184184
if(unwind_given || unwindset_given || unwindset_file_given)
185185
{
186-
unwindsett unwindset{goto_model};
186+
unwindsett unwindset;
187187

188188
if(unwind_given)
189189
unwindset.parse_unwind(cmdline.get_value("unwind"));
190190

191191
if(unwindset_file_given)
192192
{
193193
unwindset.parse_unwindset_file(
194-
cmdline.get_value("unwindset-file"), ui_message_handler);
194+
cmdline.get_value("unwindset-file"),
195+
goto_model,
196+
ui_message_handler);
195197
}
196198

197199
if(unwindset_given)
198200
{
199201
unwindset.parse_unwindset(
200202
cmdline.get_comma_separated_values("unwindset"),
203+
goto_model,
201204
ui_message_handler);
202205
}
203206

src/goto-instrument/unwindset.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void unwindsett::parse_unwind(const std::string &unwind)
2828

2929
void unwindsett::parse_unwindset_one_loop(
3030
std::string val,
31+
abstract_goto_modelt &goto_model,
3132
message_handlert &message_handler)
3233
{
3334
if(val.empty())
@@ -181,10 +182,11 @@ void unwindsett::parse_unwindset_one_loop(
181182

182183
void unwindsett::parse_unwindset(
183184
const std::list<std::string> &unwindset,
185+
abstract_goto_modelt &goto_model,
184186
message_handlert &message_handler)
185187
{
186188
for(auto &element : unwindset)
187-
parse_unwindset_one_loop(element, message_handler);
189+
parse_unwindset_one_loop(element, goto_model, message_handler);
188190
}
189191

190192
std::optional<unsigned>
@@ -211,6 +213,7 @@ unwindsett::get_limit(const irep_idt &loop_id, unsigned thread_nr) const
211213

212214
void unwindsett::parse_unwindset_file(
213215
const std::string &file_name,
216+
abstract_goto_modelt &goto_model,
214217
message_handlert &message_handler)
215218
{
216219
std::ifstream file(widen_if_needed(file_name));
@@ -225,5 +228,5 @@ void unwindsett::parse_unwindset_file(
225228
split_string(buffer.str(), ',', true, true);
226229

227230
for(auto &element : unwindset_elements)
228-
parse_unwindset_one_loop(element, message_handler);
231+
parse_unwindset_one_loop(element, goto_model, message_handler);
229232
}

src/goto-instrument/unwindset.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ class unwindsett
3030
// 2) a limit per loop, all threads
3131
// 3) a limit for a particular thread.
3232
// We use the most specific of the above.
33-
explicit unwindsett(abstract_goto_modelt &goto_model) : goto_model(goto_model)
34-
{
35-
}
33+
unwindsett() = default;
3634

3735
// global limit for all loops
3836
void parse_unwind(const std::string &unwind);
3937

4038
// limit for instances of a loop
4139
void parse_unwindset(
4240
const std::list<std::string> &unwindset,
41+
abstract_goto_modelt &goto_model,
4342
message_handlert &message_handler);
4443

4544
// queries
@@ -49,11 +48,10 @@ class unwindsett
4948
// read unwindset directives from a file
5049
void parse_unwindset_file(
5150
const std::string &file_name,
51+
abstract_goto_modelt &goto_model,
5252
message_handlert &message_handler);
5353

5454
protected:
55-
abstract_goto_modelt &goto_model;
56-
5755
std::optional<unsigned> global_limit;
5856

5957
// Limit for all instances of a loop.
@@ -68,6 +66,7 @@ class unwindsett
6866

6967
void parse_unwindset_one_loop(
7068
std::string loop_limit,
69+
abstract_goto_modelt &goto_model,
7170
message_handlert &message_handler);
7271
};
7372

unit/path_strategies.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,10 @@ void _check_with_strategy(
415415
propertiest properties(initialize_properties(goto_model));
416416
std::unique_ptr<path_storaget> worklist = get_path_strategy(strategy);
417417
guard_managert guard_manager;
418-
unwindsett unwindset{goto_model};
418+
unwindsett unwindset;
419+
unwindset.parse_unwind(options.get_option("unwind"));
420+
unwindset.parse_unwindset(
421+
options.get_list_option("unwindset"), goto_model, ui_message_handler);
419422

420423
{
421424
// Put initial state into the work list
@@ -428,7 +431,7 @@ void _check_with_strategy(
428431
*worklist,
429432
guard_manager,
430433
unwindset);
431-
setup_symex(symex, ns, options, ui_message_handler);
434+
setup_symex(symex, ns, ui_message_handler);
432435

433436
symex.initialize_path_storage_from_entry_point_of(
434437
goto_symext::get_goto_function(goto_model),
@@ -451,7 +454,7 @@ void _check_with_strategy(
451454
*worklist,
452455
guard_manager,
453456
unwindset);
454-
setup_symex(symex, ns, options, ui_message_handler);
457+
setup_symex(symex, ns, ui_message_handler);
455458

456459
symex_symbol_table = symex.resume_symex_from_saved_state(
457460
goto_symext::get_goto_function(goto_model),

0 commit comments

Comments
 (0)