@@ -10,6 +10,7 @@ Author: Daniel Kroening, kroening@kroening.com
10
10
#include < memory>
11
11
#include < sstream>
12
12
13
+ #include < util/simplify_expr.h>
13
14
#include < util/std_expr.h>
14
15
#include < util/std_code.h>
15
16
@@ -64,6 +65,58 @@ xmlt ai_domain_baset::output_xml(
64
65
65
66
/* ******************************************************************\
66
67
68
+ Function: variable_sensitivity_domaint::ai_simplify_lhs
69
+
70
+ Inputs:
71
+ condition - the expression to simplify
72
+ ns - the namespace
73
+
74
+ Outputs: True if condition did not change. False otherwise. condition
75
+ will be updated with the simplified condition if it has worked
76
+
77
+ Purpose: Use the information in the domain to simplify the expression
78
+ on the LHS of an assignment. This for example won't simplify symbols
79
+ to their values, but does simplify indices in arrays, members of
80
+ structs and dereferencing of pointers
81
+ \*******************************************************************/
82
+
83
+ bool ai_domain_baset::ai_simplify_lhs (
84
+ exprt &condition, const namespacet &ns) const
85
+ {
86
+ // Care must be taken here to give something that is still writable
87
+ if (condition.id ()==ID_index)
88
+ {
89
+ index_exprt ie=to_index_expr (condition);
90
+ bool changed=ai_simplify (ie.index (), ns);
91
+ if (changed)
92
+ condition=simplify_expr (ie, ns);
93
+
94
+ return !changed;
95
+ }
96
+ else if (condition.id ()==ID_dereference)
97
+ {
98
+ dereference_exprt de=to_dereference_expr (condition);
99
+ bool changed=ai_simplify (de.pointer (), ns);
100
+ if (changed)
101
+ condition=simplify_expr (de, ns); // So *(&x) -> x
102
+
103
+ return !changed;
104
+ }
105
+ else if (condition.id ()==ID_member)
106
+ {
107
+ member_exprt me=to_member_expr (condition);
108
+ bool changed=ai_simplify_lhs (me.compound (), ns); // <-- lhs!
109
+ if (changed)
110
+ condition=simplify_expr (me, ns);
111
+
112
+ return !changed;
113
+ }
114
+ else
115
+ return true ;
116
+ }
117
+
118
+ /* ******************************************************************\
119
+
67
120
Function: ai_baset::output
68
121
69
122
Inputs:
0 commit comments