@@ -10,25 +10,14 @@ Author: Daniel Kroening, kroening@kroening.com
1010// / Slicer for symex traces
1111
1212#include " slice.h"
13+ #include " symex_slice_class.h"
1314
15+ #include < util/find_symbols.h>
1416#include < util/std_expr.h>
1517
16- #include " symex_slice_class.h"
17-
1818void symex_slicet::get_symbols (const exprt &expr)
1919{
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);
3221}
3322
3423void symex_slicet::slice (
@@ -44,17 +33,20 @@ void symex_slicet::slice(
4433
4534void symex_slicet::slice (symex_target_equationt &equation)
4635{
36+ simple_slice (equation);
37+
4738 for (symex_target_equationt::SSA_stepst::reverse_iterator
4839 it=equation.SSA_steps .rbegin ();
4940 it!=equation.SSA_steps .rend ();
5041 it++)
51- slice (*it);
42+ {
43+ if (!it->ignore )
44+ slice (*it);
45+ }
5246}
5347
5448void symex_slicet::slice (SSA_stept &SSA_step)
5549{
56- get_symbols (SSA_step.guard );
57-
5850 switch (SSA_step.type )
5951 {
6052 case goto_trace_stept::typet::ASSERT:
@@ -66,7 +58,7 @@ void symex_slicet::slice(SSA_stept &SSA_step)
6658 break ;
6759
6860 case goto_trace_stept::typet::GOTO:
69- get_symbols (SSA_step. cond_expr );
61+ // ignore
7062 break ;
7163
7264 case goto_trace_stept::typet::LOCATION:
@@ -114,13 +106,18 @@ void symex_slicet::slice_assignment(SSA_stept &SSA_step)
114106 PRECONDITION (SSA_step.ssa_lhs .id () == ID_symbol);
115107 const irep_idt &id=SSA_step.ssa_lhs .get_identifier ();
116108
117- if (depends.find (id)==depends.end ())
109+ auto entry = depends.find (id);
110+ if (entry == depends.end ())
118111 {
119112 // we don't really need it
120113 SSA_step.ignore =true ;
121114 }
122115 else
116+ {
117+ // we have resolved this dependency
118+ depends.erase (entry);
123119 get_symbols (SSA_step.ssa_rhs );
120+ }
124121}
125122
126123void symex_slicet::slice_decl (SSA_stept &SSA_step)
@@ -163,6 +160,10 @@ void symex_slicet::collect_open_variables(
163160 get_symbols (SSA_step.cond_expr );
164161 break ;
165162
163+ case goto_trace_stept::typet::GOTO:
164+ // ignore
165+ break ;
166+
166167 case goto_trace_stept::typet::LOCATION:
167168 // ignore
168169 break ;
@@ -175,7 +176,6 @@ void symex_slicet::collect_open_variables(
175176 case goto_trace_stept::typet::OUTPUT:
176177 case goto_trace_stept::typet::INPUT:
177178 case goto_trace_stept::typet::DEAD:
178- case goto_trace_stept::typet::NONE:
179179 break ;
180180
181181 case goto_trace_stept::typet::DECL:
@@ -191,7 +191,7 @@ void symex_slicet::collect_open_variables(
191191 // ignore for now
192192 break ;
193193
194- case goto_trace_stept::typet::GOTO :
194+ case goto_trace_stept::typet::NONE :
195195 UNREACHABLE;
196196 }
197197 }
0 commit comments