@@ -24,8 +24,20 @@ class namespacet;
24
24
25
25
class value_sett
26
26
{
27
+ typedef std::function<void (exprt &, const namespacet &)> expr_simplifiert;
28
+
29
+ static expr_simplifiert default_simplifier;
30
+
27
31
public:
28
- value_sett ():location_number(0 )
32
+ value_sett ():
33
+ location_number (0 ),
34
+ simplifier (default_simplifier)
35
+ {
36
+ }
37
+
38
+ explicit value_sett (expr_simplifiert simplifier):
39
+ location_number(0 ),
40
+ simplifier(std::move(simplifier))
29
41
{
30
42
}
31
43
@@ -166,7 +178,7 @@ class value_sett
166
178
typedef std::unordered_map<idt, entryt, string_hash> valuest;
167
179
#endif
168
180
169
- void get_value_set (
181
+ void read_value_set (
170
182
const exprt &expr,
171
183
value_setst::valuest &dest,
172
184
const namespacet &ns) const ;
@@ -213,7 +225,10 @@ class value_sett
213
225
214
226
void apply_code (
215
227
const codet &code,
216
- const namespacet &ns);
228
+ const namespacet &ns)
229
+ {
230
+ apply_code_rec (code, ns);
231
+ }
217
232
218
233
void assign (
219
234
const exprt &lhs,
@@ -232,7 +247,7 @@ class value_sett
232
247
const exprt &lhs,
233
248
const namespacet &ns);
234
249
235
- void get_reference_set (
250
+ void read_reference_set (
236
251
const exprt &expr,
237
252
value_setst::valuest &dest,
238
253
const namespacet &ns) const ;
@@ -242,13 +257,6 @@ class value_sett
242
257
const namespacet &ns) const ;
243
258
244
259
protected:
245
- void get_value_set_rec (
246
- const exprt &expr,
247
- object_mapt &dest,
248
- const std::string &suffix,
249
- const typet &original_type,
250
- const namespacet &ns) const ;
251
-
252
260
void get_value_set (
253
261
const exprt &expr,
254
262
object_mapt &dest,
@@ -272,13 +280,6 @@ class value_sett
272
280
const exprt &src,
273
281
exprt &dest) const ;
274
282
275
- void assign_rec (
276
- const exprt &lhs,
277
- const object_mapt &values_rhs,
278
- const std::string &suffix,
279
- const namespacet &ns,
280
- bool add_to_sets);
281
-
282
283
void do_free (
283
284
const exprt &op,
284
285
const namespacet &ns);
@@ -287,6 +288,67 @@ class value_sett
287
288
const exprt &src,
288
289
const irep_idt &component_name,
289
290
const namespacet &ns);
291
+
292
+ // Expression simplification:
293
+
294
+ private:
295
+ // / Expression simplification function; by default, plain old
296
+ // / util/simplify_expr, but can be customised by subclass.
297
+ expr_simplifiert simplifier;
298
+
299
+ protected:
300
+ // / Run registered expression simplifier
301
+ void run_simplifier (exprt &e, const namespacet &ns)
302
+ {
303
+ simplifier (e, ns);
304
+ }
305
+
306
+ // Subclass customisation points:
307
+
308
+ protected:
309
+ // / Subclass customisation point for recursion over RHS expression:
310
+ virtual void get_value_set_rec (
311
+ const exprt &expr,
312
+ object_mapt &dest,
313
+ const std::string &suffix,
314
+ const typet &original_type,
315
+ const namespacet &ns) const ;
316
+
317
+ // / Subclass customisation point for recursion over LHS expression:
318
+ virtual void assign_rec (
319
+ const exprt &lhs,
320
+ const object_mapt &values_rhs,
321
+ const std::string &suffix,
322
+ const namespacet &ns,
323
+ bool add_to_sets);
324
+
325
+ // / Subclass customisation point for applying code to this domain:
326
+ virtual void apply_code_rec (
327
+ const codet &code,
328
+ const namespacet &ns);
329
+
330
+ private:
331
+ // / Subclass customisation point to filter or otherwise alter the value-set
332
+ // / returned from get_value_set before it is passed into assign. For example,
333
+ // / this is used in one subclass to tag and thus differentiate values that
334
+ // / originated in a particular place, vs. those that have been copied.
335
+ virtual void adjust_assign_rhs_values (
336
+ const exprt &rhs,
337
+ const namespacet &ns,
338
+ object_mapt &rhs_values) const
339
+ {
340
+ }
341
+
342
+ // / Subclass customisation point to apply global side-effects to this domain,
343
+ // / after RHS values are read but before they are written. For example, this
344
+ // / is used in a recency-analysis plugin to demote existing most-recent
345
+ // / objects to general case ones.
346
+ virtual void apply_assign_side_effects (
347
+ const exprt &lhs,
348
+ const exprt &rhs,
349
+ const namespacet &ns)
350
+ {
351
+ }
290
352
};
291
353
292
354
#endif // CPROVER_POINTER_ANALYSIS_VALUE_SET_H
0 commit comments