@@ -24,8 +24,20 @@ class namespacet;
2424
2525class value_sett
2626{
27+ typedef std::function<void (exprt &, const namespacet &)> expr_simplifiert;
28+
29+ static expr_simplifiert default_simplifier;
30+
2731public:
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))
2941 {
3042 }
3143
@@ -166,7 +178,7 @@ class value_sett
166178 typedef std::unordered_map<idt, entryt, string_hash> valuest;
167179 #endif
168180
169- void get_value_set (
181+ void read_value_set (
170182 const exprt &expr,
171183 value_setst::valuest &dest,
172184 const namespacet &ns) const ;
@@ -213,7 +225,10 @@ class value_sett
213225
214226 void apply_code (
215227 const codet &code,
216- const namespacet &ns);
228+ const namespacet &ns)
229+ {
230+ apply_code_rec (code, ns);
231+ }
217232
218233 void assign (
219234 const exprt &lhs,
@@ -232,7 +247,7 @@ class value_sett
232247 const exprt &lhs,
233248 const namespacet &ns);
234249
235- void get_reference_set (
250+ void read_reference_set (
236251 const exprt &expr,
237252 value_setst::valuest &dest,
238253 const namespacet &ns) const ;
@@ -242,13 +257,6 @@ class value_sett
242257 const namespacet &ns) const ;
243258
244259protected:
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-
252260 void get_value_set (
253261 const exprt &expr,
254262 object_mapt &dest,
@@ -272,13 +280,6 @@ class value_sett
272280 const exprt &src,
273281 exprt &dest) const ;
274282
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-
282283 void do_free (
283284 const exprt &op,
284285 const namespacet &ns);
@@ -287,6 +288,67 @@ class value_sett
287288 const exprt &src,
288289 const irep_idt &component_name,
289290 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+ }
290352};
291353
292354#endif // CPROVER_POINTER_ANALYSIS_VALUE_SET_H
0 commit comments