Skip to content

Commit 8ca4924

Browse files
authored
Merge pull request #4369 from smowton/smowton/cleanup/split-source-and-state
Split out goto_statet::source
2 parents 6461a1f + 17a039b commit 8ca4924

File tree

8 files changed

+33
-19
lines changed

8 files changed

+33
-19
lines changed

src/goto-checker/symex_bmc.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,15 @@ void symex_bmct::symex_step(
9393
}
9494
}
9595

96-
void symex_bmct::merge_goto(goto_statet &&goto_state, statet &state)
96+
void symex_bmct::merge_goto(
97+
const symex_targett::sourcet &prev_source,
98+
goto_statet &&goto_state,
99+
statet &state)
97100
{
98-
const goto_programt::const_targett prev_pc = goto_state.source.pc;
101+
const goto_programt::const_targett prev_pc = prev_source.pc;
99102
const guardt prev_guard = goto_state.guard;
100103

101-
goto_symext::merge_goto(std::move(goto_state), state);
104+
goto_symext::merge_goto(prev_source, std::move(goto_state), state);
102105

103106
PRECONDITION(prev_pc->is_goto());
104107
if(

src/goto-checker/symex_bmc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ class symex_bmct : public goto_symext
9595
void symex_step(const get_goto_functiont &get_goto_function, statet &state)
9696
override;
9797

98-
void merge_goto(goto_statet &&goto_state, statet &state) override;
98+
void merge_goto(
99+
const symex_targett::sourcet &source,
100+
goto_statet &&goto_state,
101+
statet &state) override;
99102

100103
bool should_stop_unwind(
101104
const symex_targett::sourcet &source,

src/goto-symex/frame.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ Author: Romain Brenguier, [email protected]
1313
#define CPROVER_GOTO_SYMEX_FRAME_H
1414

1515
#include "goto_state.h"
16+
#include "symex_target.h"
1617

1718
/// Stack frames -- these are used for function calls and for exceptions
1819
struct framet
1920
{
2021
// gotos
21-
using goto_state_listt = std::list<goto_statet>;
22+
using goto_state_listt =
23+
std::list<std::pair<symex_targett::sourcet, goto_statet>>;
2224

2325
// function calls
2426
irep_idt function_identifier;

src/goto-symex/goto_state.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Author: Romain Brenguier, [email protected]
1717
#include <pointer-analysis/value_set.h>
1818

1919
#include "renaming_level.h"
20-
#include "symex_target_equation.h"
2120

2221
/// Container for data that varies per program point, e.g. the constant
2322
/// propagator state, when state needs to branch. This is copied out of
@@ -41,8 +40,6 @@ class goto_statet
4140
// of the condition of the if).
4241
guardt guard;
4342

44-
symex_targett::sourcet source;
45-
4643
// Map L1 names to (L2) constants. Values will be evicted from this map
4744
// when they become non-constant. This is used to propagate values that have
4845
// been worked out to only have one possible value.
@@ -60,10 +57,8 @@ class goto_statet
6057
/// Constructors
6158
explicit goto_statet(const class goto_symex_statet &s);
6259

63-
goto_statet(
64-
const symex_targett::sourcet &_source,
65-
guard_managert &guard_manager)
66-
: guard(true_exprt(), guard_manager), source(_source)
60+
explicit goto_statet(guard_managert &guard_manager)
61+
: guard(true_exprt(), guard_manager)
6762
{
6863
}
6964
};

src/goto-symex/goto_symex.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,13 @@ class goto_symext
336336
/// Merge a single branch, the symbolic state of which is held in \p
337337
/// goto_state, into the current overall symbolic state. \p goto_state is no
338338
/// longer expected to be valid afterwards.
339+
/// \param source: source associated with the incoming \p goto_state
339340
/// \param goto_state: A state to be merged into this location
340341
/// \param state: Symbolic execution state to be updated
341-
virtual void merge_goto(goto_statet &&goto_state, statet &state);
342+
virtual void merge_goto(
343+
const symex_targett::sourcet &source,
344+
goto_statet &&goto_state,
345+
statet &state);
342346

343347
/// Merge the SSA assignments from goto_state into dest_state
344348
/// \param goto_state: A state to be merged into this location

src/goto-symex/goto_symex_state.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ static void get_l1_name(exprt &expr);
3232
goto_symex_statet::goto_symex_statet(
3333
const symex_targett::sourcet &_source,
3434
guard_managert &manager)
35-
: goto_statet(_source, manager),
35+
: goto_statet(manager),
36+
source(_source),
3637
guard_manager(manager),
3738
symex_target(nullptr),
3839
record_events(true),

src/goto-symex/goto_symex_state.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class goto_symex_statet final : public goto_statet
5454
symex_target = target;
5555
}
5656

57+
symex_targett::sourcet source;
58+
5759
/// contains symbols that are minted during symbolic execution, such as
5860
/// dynamically created objects etc. The names in this table are needed
5961
/// for error traces even after symbolic execution has finished.
@@ -219,7 +221,6 @@ inline goto_statet::goto_statet(const class goto_symex_statet &s)
219221
level2(s.level2),
220222
value_set(s.value_set),
221223
guard(s.guard),
222-
source(s.source),
223224
propagation(s.propagation),
224225
atomic_section_id(s.atomic_section_id)
225226
{

src/goto-symex/symex_goto.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void goto_symext::symex_goto(statet &state)
210210
// merge_gotos when we visit new_state_pc
211211
framet::goto_state_listt &goto_state_list =
212212
state.call_stack().top().goto_state_map[new_state_pc];
213-
goto_state_list.emplace_back(state);
213+
goto_state_list.emplace_back(state.source, state);
214214

215215
symex_transition(state, state_pc, backward);
216216

@@ -270,7 +270,7 @@ void goto_symext::symex_goto(statet &state)
270270
}
271271
else
272272
{
273-
goto_statet &new_state = goto_state_list.back();
273+
goto_statet &new_state = goto_state_list.back().second;
274274
if(!backward)
275275
{
276276
new_state.guard.add(guard_expr);
@@ -300,13 +300,18 @@ void goto_symext::merge_gotos(statet &state)
300300

301301
for(auto list_it = state_list.rbegin(); list_it != state_list.rend();
302302
++list_it)
303-
merge_goto(std::move(*list_it), state);
303+
{
304+
merge_goto(list_it->first, std::move(list_it->second), state);
305+
}
304306

305307
// clean up to save some memory
306308
frame.goto_state_map.erase(state_map_it);
307309
}
308310

309-
void goto_symext::merge_goto(goto_statet &&goto_state, statet &state)
311+
void goto_symext::merge_goto(
312+
const symex_targett::sourcet &,
313+
goto_statet &&goto_state,
314+
statet &state)
310315
{
311316
// check atomic section
312317
if(state.atomic_section_id != goto_state.atomic_section_id)

0 commit comments

Comments
 (0)