Skip to content

Commit b3c604e

Browse files
committed
Propagate merge location context down to struct members
1 parent 24b0721 commit b3c604e

File tree

8 files changed

+67
-2
lines changed

8 files changed

+67
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
struct S
2+
{
3+
int x;
4+
int y;
5+
};
6+
7+
int main()
8+
{
9+
int non_det;
10+
struct S s = {1, 3};
11+
12+
if(non_det)
13+
s.x = 2;
14+
else
15+
s.x = 3;
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--variable-sensitivity --vsd-structs every-field --vsd-values intervals --vsd-liveness --show
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^main::1::s .* \{\} @ \[1\]
7+
^main::1::s .* \{.x=\[1, 1\] @ \[2\], .y=\[3, 3\] @ \[2\]\} @ \[2\]
8+
^main::1::s .* \{.x=\[2, 3\] @ \[7\], .y=\[3, 3\] @ \[2\]\} @ \[7\]
9+
--
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--variable-sensitivity --vsd-structs every-field --vsd-values intervals --vsd-liveness --show
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^main::1::s .* \{\} @ \[1\]
7+
^main::1::s .* \{.x=\[1, 1\] @ \[2\], .y=\[3, 3\] @ \[2\]\} @ \[2\]
8+
^main::1::s .* \{.x=\[2, 3\] @ \[7\], .y=\[3, 3\] @ \[2\]\} @ \[7\]
9+
--

src/analyses/variable-sensitivity/context_abstract_object.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ abstract_object_pointert context_abstract_objectt::write_location_context(
110110
{
111111
auto result = update_location_context_internal({location});
112112

113-
auto visited_child = child_abstract_object->write_location_context(location);
114-
result->set_child(visited_child);
113+
auto updated_child = child_abstract_object->write_location_context(location);
114+
result->set_child(updated_child);
115115

116116
return result;
117117
}

src/analyses/variable-sensitivity/full_struct_abstract_object.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ abstract_object_pointert full_struct_abstract_objectt::write_location_context(
284284
return visit_sub_elements(location_update_visitort(location));
285285
}
286286

287+
abstract_object_pointert full_struct_abstract_objectt::merge_location_context(
288+
const locationt &location) const
289+
{
290+
return visit_sub_elements(merge_location_update_visitort(location));
291+
}
292+
287293
abstract_object_pointert full_struct_abstract_objectt::visit_sub_elements(
288294
const abstract_object_visitort &visitor) const
289295
{

src/analyses/variable-sensitivity/full_struct_abstract_object.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class full_struct_abstract_objectt : public abstract_aggregate_objectt<
7676
*/
7777
abstract_object_pointert
7878
write_location_context(const locationt &location) const override;
79+
abstract_object_pointert
80+
merge_location_context(const locationt &location) const override;
7981

8082
/**
8183
* Apply a visitor operation to all sub elements of this abstract_object.

src/analyses/variable-sensitivity/liveness_context.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,8 @@ liveness_contextt::merge_location_context(const locationt &location) const
213213

214214
auto update = std::dynamic_pointer_cast<liveness_contextt>(mutable_clone());
215215
update->assign_location = location;
216+
auto updated_child = child_abstract_object->merge_location_context(location);
217+
update->set_child(updated_child);
218+
216219
return update;
217220
}

src/analyses/variable-sensitivity/location_update_visitor.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,24 @@ class location_update_visitort
3030
const abstract_objectt::locationt &location;
3131
};
3232

33+
class merge_location_update_visitort
34+
: public abstract_objectt::abstract_object_visitort
35+
{
36+
public:
37+
explicit merge_location_update_visitort(
38+
const abstract_objectt::locationt &location)
39+
: location(location)
40+
{
41+
}
42+
43+
abstract_object_pointert
44+
visit(const abstract_object_pointert &element) const override
45+
{
46+
return element->merge_location_context(location);
47+
}
48+
49+
private:
50+
const abstract_objectt::locationt &location;
51+
};
52+
3353
#endif // CPROVER_ANALYSES_VARIABLE_SENSITIVITY_LOCATION_UPDATE_VISITOR_H

0 commit comments

Comments
 (0)