@@ -31,6 +31,51 @@ Date: June 2022
31
31
#include < set>
32
32
#include < vector>
33
33
34
+ // / Work around the fact that dirtyt does not look into
35
+ // / OTHER instructions
36
+ class dirty_altt : public dirtyt
37
+ {
38
+ public:
39
+ dirty_altt () : dirtyt()
40
+ {
41
+ }
42
+
43
+ explicit dirty_altt (const goto_functiont &goto_function)
44
+ : dirtyt(goto_function)
45
+ {
46
+ collect_other (goto_function);
47
+ }
48
+
49
+ explicit dirty_altt (const goto_functionst &goto_functions)
50
+ : dirtyt(goto_functions)
51
+ {
52
+ for (const auto &gf_entry : goto_functions.function_map )
53
+ collect_other (gf_entry.second );
54
+ }
55
+
56
+ protected:
57
+ void collect_other (const goto_functiont &goto_function)
58
+ {
59
+ for (const auto &i : goto_function.body .instructions )
60
+ {
61
+ if (i.is_other ())
62
+ {
63
+ auto &statement = i.get_other ().get_statement ();
64
+ if (
65
+ statement == ID_array_set || statement == ID_array_copy ||
66
+ statement == ID_array_replace || statement == ID_array_equal ||
67
+ statement == ID_havoc_object)
68
+ {
69
+ for (const auto &op : i.get_other ().operands ())
70
+ {
71
+ find_dirty (op);
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ };
78
+
34
79
// / Stores information about a goto function computed from its CFG.
35
80
// /
36
81
// / The methods of this class provide information about identifiers
@@ -110,7 +155,7 @@ class function_cfg_infot : public cfg_infot
110
155
{
111
156
public:
112
157
explicit function_cfg_infot (const goto_functiont &_goto_function)
113
- : dirty_analysis (_goto_function), locals(_goto_function)
158
+ : is_dirty (_goto_function), locals(_goto_function)
114
159
{
115
160
parameters.insert (
116
161
_goto_function.parameter_identifiers .begin (),
@@ -128,15 +173,11 @@ class function_cfg_infot : public cfg_infot
128
173
// / or is a local that is dirty.
129
174
bool is_not_local_or_dirty_local (const irep_idt &ident) const override
130
175
{
131
- if (is_local (ident))
132
- return dirty_analysis.get_dirty_ids ().find (ident) !=
133
- dirty_analysis.get_dirty_ids ().end ();
134
- else
135
- return true ;
176
+ return is_local (ident) ? is_dirty (ident) : true ;
136
177
}
137
178
138
179
private:
139
- const dirtyt dirty_analysis ;
180
+ const dirty_altt is_dirty ;
140
181
const localst locals;
141
182
std::unordered_set<irep_idt> parameters;
142
183
};
@@ -146,7 +187,7 @@ class loop_cfg_infot : public cfg_infot
146
187
{
147
188
public:
148
189
loop_cfg_infot (goto_functiont &_goto_function, const loopt &loop)
149
- : dirty_analysis (_goto_function)
190
+ : is_dirty (_goto_function)
150
191
{
151
192
for (const auto &t : loop)
152
193
{
@@ -166,8 +207,7 @@ class loop_cfg_infot : public cfg_infot
166
207
bool is_not_local_or_dirty_local (const irep_idt &ident) const override
167
208
{
168
209
if (is_local (ident))
169
- return dirty_analysis.get_dirty_ids ().find (ident) !=
170
- dirty_analysis.get_dirty_ids ().end ();
210
+ return is_dirty (ident);
171
211
else
172
212
return true ;
173
213
}
@@ -190,8 +230,7 @@ class loop_cfg_infot : public cfg_infot
190
230
}
191
231
192
232
private:
193
- const dirtyt dirty_analysis ;
233
+ const dirty_altt is_dirty ;
194
234
std::unordered_set<irep_idt> locals;
195
235
};
196
-
197
236
#endif
0 commit comments