10
10
// / Slicer for symex traces
11
11
12
12
#include " slice.h"
13
+ #include " symex_slice_class.h"
13
14
15
+ #include < util/find_symbols.h>
14
16
#include < util/std_expr.h>
15
17
16
- #include " symex_slice_class.h"
17
-
18
18
void symex_slicet::get_symbols (const exprt &expr)
19
19
{
20
- get_symbols (expr.type ());
21
-
22
- forall_operands (it, expr)
23
- get_symbols (*it);
24
-
25
- if (expr.id ()==ID_symbol)
26
- depends.insert (to_symbol_expr (expr).get_identifier ());
27
- }
28
-
29
- void symex_slicet::get_symbols (const typet &)
30
- {
31
- // TODO
20
+ find_symbols (expr, depends);
32
21
}
33
22
34
23
void symex_slicet::slice (
@@ -44,17 +33,20 @@ void symex_slicet::slice(
44
33
45
34
void symex_slicet::slice (symex_target_equationt &equation)
46
35
{
36
+ simple_slice (equation);
37
+
47
38
for (symex_target_equationt::SSA_stepst::reverse_iterator
48
39
it=equation.SSA_steps .rbegin ();
49
40
it!=equation.SSA_steps .rend ();
50
41
it++)
51
- slice (*it);
42
+ {
43
+ if (!it->ignore )
44
+ slice (*it);
45
+ }
52
46
}
53
47
54
48
void symex_slicet::slice (SSA_stept &SSA_step)
55
49
{
56
- get_symbols (SSA_step.guard );
57
-
58
50
switch (SSA_step.type )
59
51
{
60
52
case goto_trace_stept::typet::ASSERT:
@@ -66,7 +58,7 @@ void symex_slicet::slice(SSA_stept &SSA_step)
66
58
break ;
67
59
68
60
case goto_trace_stept::typet::GOTO:
69
- get_symbols (SSA_step. cond_expr );
61
+ // ignore
70
62
break ;
71
63
72
64
case goto_trace_stept::typet::LOCATION:
@@ -114,13 +106,18 @@ void symex_slicet::slice_assignment(SSA_stept &SSA_step)
114
106
PRECONDITION (SSA_step.ssa_lhs .id () == ID_symbol);
115
107
const irep_idt &id=SSA_step.ssa_lhs .get_identifier ();
116
108
117
- if (depends.find (id)==depends.end ())
109
+ auto entry = depends.find (id);
110
+ if (entry == depends.end ())
118
111
{
119
112
// we don't really need it
120
113
SSA_step.ignore =true ;
121
114
}
122
115
else
116
+ {
117
+ // we have resolved this dependency
118
+ depends.erase (entry);
123
119
get_symbols (SSA_step.ssa_rhs );
120
+ }
124
121
}
125
122
126
123
void symex_slicet::slice_decl (SSA_stept &SSA_step)
@@ -163,6 +160,10 @@ void symex_slicet::collect_open_variables(
163
160
get_symbols (SSA_step.cond_expr );
164
161
break ;
165
162
163
+ case goto_trace_stept::typet::GOTO:
164
+ // ignore
165
+ break ;
166
+
166
167
case goto_trace_stept::typet::LOCATION:
167
168
// ignore
168
169
break ;
@@ -175,7 +176,6 @@ void symex_slicet::collect_open_variables(
175
176
case goto_trace_stept::typet::OUTPUT:
176
177
case goto_trace_stept::typet::INPUT:
177
178
case goto_trace_stept::typet::DEAD:
178
- case goto_trace_stept::typet::NONE:
179
179
break ;
180
180
181
181
case goto_trace_stept::typet::DECL:
@@ -191,7 +191,7 @@ void symex_slicet::collect_open_variables(
191
191
// ignore for now
192
192
break ;
193
193
194
- case goto_trace_stept::typet::GOTO :
194
+ case goto_trace_stept::typet::NONE :
195
195
UNREACHABLE;
196
196
}
197
197
}
0 commit comments