@@ -43,6 +43,36 @@ exprt assigns_clauset::targett::normalize(const exprt &expr)
4343 return to_index_expr (object).array ();
4444}
4545
46+ assigns_clauset::assigns_clauset (
47+ const exprt::operandst &assigns,
48+ const messaget &log,
49+ const namespacet &ns)
50+ : log(log), ns(ns)
51+ {
52+ for (const auto &target_expr : assigns)
53+ {
54+ add_to_write_set (target_expr);
55+ }
56+ }
57+
58+ void assigns_clauset::add_to_write_set (const exprt &target_expr)
59+ {
60+ auto insertion_succeeded = write_set.emplace (*this , target_expr).second ;
61+
62+ if (!insertion_succeeded)
63+ {
64+ log.warning () << " Ignored duplicate expression '"
65+ << from_expr (ns, target_expr.id (), target_expr)
66+ << " ' in assigns clause at "
67+ << target_expr.source_location ().as_string () << messaget::eom;
68+ }
69+ }
70+
71+ void assigns_clauset::remove_from_write_set (const exprt &target_expr)
72+ {
73+ write_set.erase (targett (*this , target_expr));
74+ }
75+
4676exprt assigns_clauset::targett::generate_containment_check (
4777 const address_of_exprt &lhs_address) const
4878{
@@ -91,54 +121,11 @@ exprt assigns_clauset::targett::generate_containment_check(
91121 return or_exprt{not_exprt{address_validity}, conjunction (containment_check)};
92122}
93123
94- assigns_clauset::assigns_clauset (
95- const exprt::operandst &assigns,
96- const messaget &log,
97- const namespacet &ns)
98- : log(log), ns(ns)
99- {
100- for (const auto &target_expr : assigns)
101- {
102- add_to_global_write_set (target_expr);
103- }
104- }
105-
106- void assigns_clauset::add_to_global_write_set (const exprt &target_expr)
107- {
108- auto insertion_succeeded =
109- global_write_set.emplace (*this , target_expr).second ;
110-
111- if (!insertion_succeeded)
112- {
113- log.warning () << " Ignored duplicate expression '"
114- << from_expr (ns, target_expr.id (), target_expr)
115- << " ' in assigns clause at "
116- << target_expr.source_location ().as_string () << messaget::eom;
117- }
118- }
119-
120- void assigns_clauset::remove_from_global_write_set (const exprt &target_expr)
121- {
122- global_write_set.erase (targett (*this , target_expr));
123- }
124-
125- void assigns_clauset::add_to_local_write_set (const exprt &expr)
126- {
127- local_write_set.emplace (*this , expr);
128- }
129-
130- void assigns_clauset::remove_from_local_write_set (const exprt &expr)
131- {
132- local_write_set.erase (targett (*this , expr));
133- }
134-
135124goto_programt
136125assigns_clauset::generate_havoc_code (const source_locationt &location) const
137126{
138127 modifiest modifies;
139- for (const auto &target : global_write_set)
140- modifies.insert (target.address .object ());
141- for (const auto &target : local_write_set)
128+ for (const auto &target : write_set)
142129 modifies.insert (target.address .object ());
143130
144131 goto_programt havoc_statements;
@@ -151,17 +138,13 @@ assigns_clauset::generate_havoc_code(const source_locationt &location) const
151138exprt assigns_clauset::generate_containment_check (const exprt &lhs) const
152139{
153140 // If write set is empty, no assignment is allowed.
154- if (global_write_set. empty () && local_write_set .empty ())
141+ if (write_set .empty ())
155142 return false_exprt ();
156143
157144 const auto lhs_address = address_of_exprt (targett::normalize (lhs));
158145
159146 exprt::operandst condition;
160- for (const auto &target : local_write_set)
161- {
162- condition.push_back (target.generate_containment_check (lhs_address));
163- }
164- for (const auto &target : global_write_set)
147+ for (const auto &target : write_set)
165148 {
166149 condition.push_back (target.generate_containment_check (lhs_address));
167150 }
@@ -171,26 +154,14 @@ exprt assigns_clauset::generate_containment_check(const exprt &lhs) const
171154exprt assigns_clauset::generate_subset_check (
172155 const assigns_clauset &subassigns) const
173156{
174- if (subassigns.global_write_set .empty ())
157+ if (subassigns.write_set .empty ())
175158 return true_exprt ();
176159
177- INVARIANT (
178- subassigns.local_write_set .empty (),
179- " Local write set for function calls should be empty at this point.\n " +
180- subassigns.local_write_set .begin ()
181- ->address .source_location ()
182- .as_string ());
183-
184160 exprt result = true_exprt ();
185- for (const auto &subtarget : subassigns.global_write_set )
161+ for (const auto &subtarget : subassigns.write_set )
186162 {
187163 exprt::operandst current_subtarget_found_conditions;
188- for (const auto &target : global_write_set)
189- {
190- current_subtarget_found_conditions.push_back (
191- target.generate_containment_check (subtarget.address ));
192- }
193- for (const auto &target : local_write_set)
164+ for (const auto &target : write_set)
194165 {
195166 current_subtarget_found_conditions.push_back (
196167 target.generate_containment_check (subtarget.address ));
0 commit comments