Skip to content

Commit add7137

Browse files
committed
Simplify update_location_context
Eliminate update_sub_elements flag parameter as it would always be true.
1 parent ea9ce99 commit add7137

10 files changed

+21
-44
lines changed

src/analyses/variable-sensitivity/abstract_object.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,11 @@ bool abstract_objectt::should_use_base_meet(
244244
abstract_object_pointert
245245
abstract_objectt::write_location_context(const locationt &location) const
246246
{
247-
return update_location_context({location}, true);
247+
return update_location_context({location});
248248
}
249249

250-
abstract_object_pointert abstract_objectt::update_location_context(
251-
const locationst &locations,
252-
const bool update_sub_elements) const
250+
abstract_object_pointert
251+
abstract_objectt::update_location_context(const locationst &locations) const
253252
{
254253
return shared_from_this();
255254
}

src/analyses/variable-sensitivity/abstract_object.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,12 @@ class abstract_objectt : public std::enable_shared_from_this<abstract_objectt>
297297
* propogating the update to any children of this abstract object.
298298
*
299299
* \param locations the set of locations to be updated
300-
* \param update_sub_elements if true, propogate the update operation to any
301-
* children of this abstract object
302300
*
303301
* \return a clone of this abstract object with it's location context
304302
* updated
305303
*/
306-
virtual abstract_object_pointert update_location_context(
307-
const locationst &locations,
308-
const bool update_sub_elements) const;
304+
virtual abstract_object_pointert
305+
update_location_context(const locationst &locations) const;
309306

310307
// Const versions must perform copy-on-write
311308
abstract_object_pointert make_top() const

src/analyses/variable-sensitivity/context_abstract_object.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,13 @@ abstract_object_pointert context_abstract_objectt::expression_transform(
106106
}
107107

108108
abstract_object_pointert context_abstract_objectt::update_location_context(
109-
const abstract_objectt::locationst &locations,
110-
const bool update_sub_elements) const
109+
const abstract_objectt::locationst &locations) const
111110
{
112111
auto result = update_location_context_internal(locations);
113112

114-
if(update_sub_elements)
115-
{
116-
abstract_object_pointert visited_child =
117-
child_abstract_object->update_location_context(
118-
locations, update_sub_elements);
119-
result->set_child(visited_child);
120-
}
113+
abstract_object_pointert visited_child =
114+
child_abstract_object->update_location_context(locations);
115+
result->set_child(visited_child);
121116

122117
return result;
123118
}

src/analyses/variable-sensitivity/context_abstract_object.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ class context_abstract_objectt : public abstract_objectt
8181
const abstract_environmentt &environment,
8282
const namespacet &ns) const override;
8383

84-
abstract_object_pointert update_location_context(
85-
const abstract_objectt::locationst &locations,
86-
const bool update_sub_elements) const override;
84+
abstract_object_pointert
85+
update_location_context(const locationst &locations) const override;
8786

8887
void output(std::ostream &out, const class ai_baset &ai, const namespacet &ns)
8988
const override;

src/analyses/variable-sensitivity/full_array_abstract_object.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,8 @@ abstract_object_pointert full_array_abstract_objectt::get_top_entry(
378378
}
379379

380380
abstract_object_pointert full_array_abstract_objectt::update_location_context(
381-
const locationst &locations,
382-
const bool update_sub_elements) const
381+
const locationst &locations) const
383382
{
384-
if(!update_sub_elements)
385-
return shared_from_this();
386-
387383
return visit_sub_elements(location_update_visitort(locations));
388384
}
389385

src/analyses/variable-sensitivity/full_array_abstract_object.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,12 @@ class full_array_abstract_objectt : public abstract_aggregate_objectt<
6565
* propogating the update to any children of this abstract object.
6666
*
6767
* \param locations the set of locations to be updated
68-
* \param update_sub_elements if true, propogate the update operation to any
69-
* children of this abstract object
7068
*
7169
* \return a clone of this abstract object with it's location context
7270
* updated
7371
*/
74-
abstract_object_pointert update_location_context(
75-
const locationst &locations,
76-
const bool update_sub_elements) const override;
72+
abstract_object_pointert
73+
update_location_context(const locationst &locations) const override;
7774

7875
/**
7976
* Apply a visitor operation to all sub elements of this abstract_object.

src/analyses/variable-sensitivity/full_struct_abstract_object.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,8 @@ abstract_object_pointert full_struct_abstract_objectt::merge_constant_structs(
279279
}
280280

281281
abstract_object_pointert full_struct_abstract_objectt::update_location_context(
282-
const locationst &locations,
283-
const bool update_sub_elements) const
282+
const locationst &locations) const
284283
{
285-
if(!update_sub_elements)
286-
return shared_from_this();
287-
288284
return visit_sub_elements(location_update_visitort(locations));
289285
}
290286

src/analyses/variable-sensitivity/full_struct_abstract_object.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,12 @@ class full_struct_abstract_objectt : public abstract_aggregate_objectt<
7171
* propogating the update to any children of this abstract object.
7272
*
7373
* \param locations the set of locations to be updated
74-
* \param update_sub_elements if true, propogate the update operation to any
75-
* children of this abstract object
7674
*
7775
* \return a clone of this abstract object with it's location context
7876
* updated
7977
*/
80-
abstract_object_pointert update_location_context(
81-
const locationst &locations,
82-
const bool update_sub_elements) const override;
78+
abstract_object_pointert
79+
update_location_context(const locationst &locations) const override;
8380

8481
/**
8582
* Apply a visitor operation to all sub elements of this abstract_object.

src/analyses/variable-sensitivity/location_update_visitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class location_update_visitort
2424
abstract_object_pointert
2525
visit(const abstract_object_pointert &element) const override
2626
{
27-
return element->update_location_context(locations, true);
27+
return element->update_location_context(locations);
2828
}
2929

3030
private:

src/analyses/variable-sensitivity/write_location_context.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ write_location_contextt::abstract_object_merge_internal(
175175
// If the union is larger than the initial set, then update.
176176
if(location_union.size() > get_last_written_locations().size())
177177
{
178-
abstract_object_pointert result = mutable_clone();
179-
return result->update_location_context(location_union, false);
178+
auto result =
179+
std::dynamic_pointer_cast<write_location_contextt>(mutable_clone());
180+
return result->update_location_context_internal(location_union);
180181
}
181182
}
182183
return shared_from_this();

0 commit comments

Comments
 (0)