Skip to content

Commit fec57f0

Browse files
Move goto_statet definition to its own file
Having one class per header file makes it easier to navigate the code and find what we want.
1 parent 272ba02 commit fec57f0

File tree

5 files changed

+95
-63
lines changed

5 files changed

+95
-63
lines changed

src/goto-symex/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
SRC = auto_objects.cpp \
22
build_goto_trace.cpp \
3+
goto_state.cpp \
34
goto_symex.cpp \
45
goto_symex_state.cpp \
56
memory_model.cpp \

src/goto-symex/goto_state.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*******************************************************************\
2+
3+
Module: Symbolic Execution
4+
5+
Author: Romain Brenguier, [email protected]
6+
7+
\*******************************************************************/
8+
9+
#include "goto_state.h"
10+
11+
#include <util/format_expr.h>
12+
13+
/// Print the constant propagation map in a human-friendly format.
14+
/// This is primarily for use from the debugger; please don't delete me just
15+
/// because there aren't any current callers.
16+
void goto_statet::output_propagation_map(std::ostream &out)
17+
{
18+
for(const auto &name_value : propagation)
19+
{
20+
out << name_value.first << " <- " << format(name_value.second) << "\n";
21+
}
22+
}

src/goto-symex/goto_state.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*******************************************************************\
2+
3+
Module: Symbolic Execution
4+
5+
Author: Romain Brenguier, [email protected]
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// goto_statet class definition
11+
12+
#ifndef CPROVER_GOTO_SYMEX_GOTO_STATE_H
13+
#define CPROVER_GOTO_SYMEX_GOTO_STATE_H
14+
15+
#include <analyses/local_safe_pointers.h>
16+
#include <pointer-analysis/value_set.h>
17+
#include <util/guard.h>
18+
19+
#include "renaming_level.h"
20+
#include "symex_target_equation.h"
21+
22+
/// Container for data that varies per program point, e.g. the constant
23+
/// propagator state, when state needs to branch. This is copied out of
24+
/// goto_symex_statet at a control-flow fork and then back into it at a
25+
/// control-flow merge.
26+
class goto_statet
27+
{
28+
public:
29+
/// Distance from entry
30+
unsigned depth = 0;
31+
32+
symex_level2t level2;
33+
34+
/// Uses level 1 names, and is used to do dereferencing
35+
value_sett value_set;
36+
37+
// A guard is a particular condition that has to pass for an instruction
38+
// to be executed. The easiest example is an if/else: each instruction along
39+
// the if branch will be guarded by the condition of the if (and if there
40+
// is an else branch then instructions on it will be guarded by the negation
41+
// of the condition of the if).
42+
guardt guard{true_exprt{}};
43+
44+
symex_targett::sourcet source;
45+
46+
// Map L1 names to (L2) constants. Values will be evicted from this map
47+
// when they become non-constant. This is used to propagate values that have
48+
// been worked out to only have one possible value.
49+
//
50+
// "constants" can include symbols, but only in the context of an address-of
51+
// op (i.e. &x can be propagated), and an address-taken thing should only be
52+
// L1.
53+
std::map<irep_idt, exprt> propagation;
54+
55+
void output_propagation_map(std::ostream &);
56+
57+
/// Threads
58+
unsigned atomic_section_id = 0;
59+
60+
std::unordered_map<irep_idt, local_safe_pointerst> safe_pointers;
61+
unsigned total_vccs = 0;
62+
unsigned remaining_vccs = 0;
63+
64+
/// Constructors
65+
explicit goto_statet(const class goto_symex_statet &s);
66+
explicit goto_statet(const symex_targett::sourcet &_source) : source(_source)
67+
{
68+
}
69+
};
70+
71+
#endif // CPROVER_GOTO_SYMEX_GOTO_STATE_H

src/goto-symex/goto_symex_state.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -785,14 +785,3 @@ void goto_symex_statet::print_backtrace(std::ostream &out) const
785785
<< frame.calling_location.pc->location_number << "\n";
786786
}
787787
}
788-
789-
/// Print the constant propagation map in a human-friendly format.
790-
/// This is primarily for use from the debugger; please don't delete me just
791-
/// because there aren't any current callers.
792-
void goto_statet::output_propagation_map(std::ostream &out)
793-
{
794-
for(const auto &name_value : propagation)
795-
{
796-
out << name_value.first << " <- " << format(name_value.second) << "\n";
797-
}
798-
}

src/goto-symex/goto_symex_state.h

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,69 +16,18 @@ Author: Daniel Kroening, [email protected]
1616
#include <unordered_set>
1717

1818
#include <analyses/dirty.h>
19-
#include <analyses/local_safe_pointers.h>
2019

2120
#include <util/invariant.h>
2221
#include <util/guard.h>
2322
#include <util/std_expr.h>
2423
#include <util/ssa_expr.h>
2524
#include <util/make_unique.h>
26-
27-
#include <pointer-analysis/value_set.h>
2825
#include <goto-programs/goto_function.h>
2926

27+
#include "goto_state.h"
3028
#include "renaming_level.h"
3129
#include "symex_target_equation.h"
3230

33-
/// Container for data that varies per program point, e.g. the constant
34-
/// propagator state, when state needs to branch. This is copied out of
35-
/// goto_symex_statet at a control-flow fork and then back into it at a
36-
/// control-flow merge.
37-
class goto_statet
38-
{
39-
public:
40-
/// Distance from entry
41-
unsigned depth = 0;
42-
43-
symex_level2t level2;
44-
45-
/// Uses level 1 names, and is used to do dereferencing
46-
value_sett value_set;
47-
48-
// A guard is a particular condition that has to pass for an instruction
49-
// to be executed. The easiest example is an if/else: each instruction along
50-
// the if branch will be guarded by the condition of the if (and if there
51-
// is an else branch then instructions on it will be guarded by the negation
52-
// of the condition of the if).
53-
guardt guard{true_exprt{}};
54-
55-
symex_targett::sourcet source;
56-
57-
// Map L1 names to (L2) constants. Values will be evicted from this map
58-
// when they become non-constant. This is used to propagate values that have
59-
// been worked out to only have one possible value.
60-
//
61-
// "constants" can include symbols, but only in the context of an address-of
62-
// op (i.e. &x can be propagated), and an address-taken thing should only be
63-
// L1.
64-
std::map<irep_idt, exprt> propagation;
65-
66-
void output_propagation_map(std::ostream &);
67-
68-
/// Threads
69-
unsigned atomic_section_id = 0;
70-
71-
std::unordered_map<irep_idt, local_safe_pointerst> safe_pointers;
72-
unsigned total_vccs = 0;
73-
unsigned remaining_vccs = 0;
74-
75-
/// Constructors
76-
explicit goto_statet(const class goto_symex_statet &s);
77-
explicit goto_statet(const symex_targett::sourcet &_source) : source(_source)
78-
{
79-
}
80-
};
81-
8231
// stack frames -- these are used for function calls and
8332
// for exceptions
8433
struct framet

0 commit comments

Comments
 (0)