Skip to content

Commit 3b908f8

Browse files
authored
Merge pull request #7275 from tautschnig/cleanup/symex-return
goto-symex interface: return symbol tables by value
2 parents dbbcf31 + 94933ad commit 3b908f8

File tree

7 files changed

+36
-47
lines changed

7 files changed

+36
-47
lines changed

Diff for: src/goto-checker/multi_path_symex_only_checker.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ void multi_path_symex_only_checkert::generate_equation()
7474
{
7575
const auto symex_start = std::chrono::steady_clock::now();
7676

77-
symex.symex_from_entry_point_of(
78-
goto_symext::get_goto_function(goto_model), symex_symbol_table);
77+
symex_symbol_table =
78+
symex.symex_from_entry_point_of(goto_symext::get_goto_function(goto_model));
7979

8080
const auto symex_stop = std::chrono::steady_clock::now();
8181
std::chrono::duration<double> symex_runtime =

Diff for: src/goto-checker/single_path_symex_only_checker.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,8 @@ bool single_path_symex_only_checkert::resume_path(path_storaget::patht &path)
9999
unwindset);
100100
setup_symex(symex);
101101

102-
symex.resume_symex_from_saved_state(
103-
goto_symext::get_goto_function(goto_model),
104-
path.state,
105-
&path.equation,
106-
symex_symbol_table);
102+
symex_symbol_table = symex.resume_symex_from_saved_state(
103+
goto_symext::get_goto_function(goto_model), path.state, &path.equation);
107104

108105
const auto symex_stop = std::chrono::steady_clock::now();
109106
symex_runtime += std::chrono::duration<double>(symex_stop - symex_start);

Diff for: src/goto-checker/symex_bmc_incremental_one_loop.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool symex_bmc_incremental_one_loopt::from_entry_point_of(
128128
{
129129
state = initialize_entry_point_state(get_goto_function);
130130

131-
symex_with_state(*state, get_goto_function, new_symbol_table);
131+
new_symbol_table = symex_with_state(*state, get_goto_function);
132132

133133
return should_pause_symex;
134134
}
@@ -138,7 +138,7 @@ bool symex_bmc_incremental_one_loopt::resume(
138138
{
139139
should_pause_symex = false;
140140

141-
symex_with_state(*state, get_goto_function, state->symbol_table);
141+
state->symbol_table = symex_with_state(*state, get_goto_function);
142142

143143
return should_pause_symex;
144144
}

Diff for: src/goto-instrument/accelerate/scratch_program.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool scratch_programt::check_sat(bool do_slice, guard_managert &guard_manager)
4747

4848
symex_state = symex.initialize_entry_point_state(get_goto_function);
4949

50-
symex.symex_with_state(*symex_state, get_goto_function, symex_symbol_table);
50+
symex_symbol_table = symex.symex_with_state(*symex_state, get_goto_function);
5151

5252
if(do_slice)
5353
{

Diff for: src/goto-symex/goto_symex.h

+15-16
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ class goto_symext
9898
/// having the state around afterwards.
9999
/// \param get_goto_function: The delegate to retrieve function bodies (see
100100
/// \ref get_goto_functiont)
101-
/// \param new_symbol_table: A symbol table to store the symbols added during
102-
/// symbolic execution
103-
virtual void symex_from_entry_point_of(
104-
const get_goto_functiont &get_goto_function,
105-
symbol_tablet &new_symbol_table);
101+
/// \return A symbol table holding the symbols added during symbolic
102+
/// execution.
103+
NODISCARD
104+
virtual symbol_tablet
105+
symex_from_entry_point_of(const get_goto_functiont &get_goto_function);
106106

107107
/// Puts the initial state of the entry point function into the path storage
108108
virtual void initialize_path_storage_from_entry_point_of(
@@ -117,13 +117,13 @@ class goto_symext
117117
/// \ref get_goto_functiont)
118118
/// \param saved_state: The symbolic execution state to resume from
119119
/// \param saved_equation: The equation as previously built up
120-
/// \param new_symbol_table: A symbol table to store the symbols added during
121-
/// symbolic execution
122-
virtual void resume_symex_from_saved_state(
120+
/// \return A symbol table holding the symbols added during symbolic
121+
/// execution.
122+
NODISCARD
123+
virtual symbol_tablet resume_symex_from_saved_state(
123124
const get_goto_functiont &get_goto_function,
124125
const statet &saved_state,
125-
symex_target_equationt *saved_equation,
126-
symbol_tablet &new_symbol_table);
126+
symex_target_equationt *saved_equation);
127127

128128
//// \brief Symbolically execute the entire program starting from entry point
129129
///
@@ -135,12 +135,11 @@ class goto_symext
135135
/// \param state: The symbolic execution state to use for the execution
136136
/// \param get_goto_functions: A functor to retrieve function bodies to
137137
/// execute
138-
/// \param new_symbol_table: A symbol table to store the symbols added during
139-
/// symbolic execution
140-
virtual void symex_with_state(
141-
statet &state,
142-
const get_goto_functiont &get_goto_functions,
143-
symbol_tablet &new_symbol_table);
138+
/// \return A symbol table holding the symbols added during symbolic
139+
/// execution.
140+
NODISCARD
141+
virtual symbol_tablet
142+
symex_with_state(statet &state, const get_goto_functiont &get_goto_functions);
144143

145144
/// \brief Set when states are pushed onto the workqueue
146145
/// If this flag is set at the end of a symbolic execution run, it means that

Diff for: src/goto-symex/symex_main.cpp

+12-18
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,9 @@ void goto_symext::symex_threaded_step(
320320
}
321321
}
322322

323-
void goto_symext::symex_with_state(
323+
symbol_tablet goto_symext::symex_with_state(
324324
statet &state,
325-
const get_goto_functiont &get_goto_function,
326-
symbol_tablet &new_symbol_table)
325+
const get_goto_functiont &get_goto_function)
327326
{
328327
// resets the namespace to only wrap a single symbol table, and does so upon
329328
// destruction of an object of this type; instantiating the type is thus all
@@ -360,28 +359,27 @@ void goto_symext::symex_with_state(
360359

361360
symex_threaded_step(state, get_goto_function);
362361
if(should_pause_symex)
363-
return;
362+
return state.symbol_table;
363+
364364
while(!state.call_stack().empty())
365365
{
366366
state.has_saved_jump_target = false;
367367
state.has_saved_next_instruction = false;
368368
symex_threaded_step(state, get_goto_function);
369369
if(should_pause_symex)
370-
return;
370+
return state.symbol_table;
371371
}
372372

373373
// Clients may need to construct a namespace with both the names in
374374
// the original goto-program and the names generated during symbolic
375375
// execution, so return the names generated through symbolic execution
376-
// through `new_symbol_table`.
377-
new_symbol_table = state.symbol_table;
376+
return state.symbol_table;
378377
}
379378

380-
void goto_symext::resume_symex_from_saved_state(
379+
symbol_tablet goto_symext::resume_symex_from_saved_state(
381380
const get_goto_functiont &get_goto_function,
382381
const statet &saved_state,
383-
symex_target_equationt *const saved_equation,
384-
symbol_tablet &new_symbol_table)
382+
symex_target_equationt *const saved_equation)
385383
{
386384
// saved_state contains a pointer to a symex_target_equationt that is
387385
// almost certainly stale. This is because equations are owned by bmcts,
@@ -393,10 +391,7 @@ void goto_symext::resume_symex_from_saved_state(
393391

394392
// Do NOT do the same initialization that `symex_with_state` does for a
395393
// fresh state, as that would clobber the saved state's program counter
396-
symex_with_state(
397-
state,
398-
get_goto_function,
399-
new_symbol_table);
394+
return symex_with_state(state, get_goto_function);
400395
}
401396

402397
std::unique_ptr<goto_symext::statet> goto_symext::initialize_entry_point_state(
@@ -466,13 +461,12 @@ std::unique_ptr<goto_symext::statet> goto_symext::initialize_entry_point_state(
466461
return state;
467462
}
468463

469-
void goto_symext::symex_from_entry_point_of(
470-
const get_goto_functiont &get_goto_function,
471-
symbol_tablet &new_symbol_table)
464+
symbol_tablet goto_symext::symex_from_entry_point_of(
465+
const get_goto_functiont &get_goto_function)
472466
{
473467
auto state = initialize_entry_point_state(get_goto_function);
474468

475-
symex_with_state(*state, get_goto_function, new_symbol_table);
469+
return symex_with_state(*state, get_goto_function);
476470
}
477471

478472
void goto_symext::initialize_path_storage_from_entry_point_of(

Diff for: unit/path_strategies.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,10 @@ void _check_with_strategy(
446446
unwindset);
447447
setup_symex(symex, ns, options, ui_message_handler);
448448

449-
symex.resume_symex_from_saved_state(
449+
symex_symbol_table = symex.resume_symex_from_saved_state(
450450
goto_symext::get_goto_function(goto_model),
451451
resume.state,
452-
&resume.equation,
453-
symex_symbol_table);
452+
&resume.equation);
454453
postprocess_equation(
455454
symex, resume.equation, options, ns, ui_message_handler);
456455

0 commit comments

Comments
 (0)