File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -99,9 +99,11 @@ static json_objectt value_set_dereference_stats_to_json(
99
99
return json_result;
100
100
}
101
101
102
- optionalt<exprt> value_set_dereferencet::try_add_offset_to_indices (
103
- const exprt &expr,
104
- const exprt &offset_elements)
102
+ // / If `expr` is of the form (c1 ? e1[o1] : c2 ? e2[o2] : c3 ? ...)
103
+ // / then return `c1 ? e1[o1 + offset] : e2[o2 + offset] : c3 ? ...`
104
+ // / otherwise return an empty optionalt.
105
+ static optionalt<exprt>
106
+ try_add_offset_to_indices (const exprt &expr, const exprt &offset_elements)
105
107
{
106
108
if (const auto *index_expr = expr_try_dynamic_cast<index_exprt>(expr))
107
109
{
@@ -123,6 +125,13 @@ optionalt<exprt> value_set_dereferencet::try_add_offset_to_indices(
123
125
return {};
124
126
return if_exprt{if_expr->cond (), *true_case, *false_case};
125
127
}
128
+ else if (can_cast_expr<typecast_exprt>(expr))
129
+ {
130
+ // the case of a type cast is _not_ handled here, because that would require
131
+ // doing arithmetic on the offset, and may result in an offset into some
132
+ // sub-element
133
+ return {};
134
+ }
126
135
else
127
136
{
128
137
return {};
Original file line number Diff line number Diff line change @@ -54,12 +54,6 @@ class value_set_dereferencet final
54
54
// / \param display_points_to_sets: Display size and contents of points to sets
55
55
exprt dereference (const exprt &pointer, bool display_points_to_sets = false );
56
56
57
- // / If `expr` is of the form (c1 ? e1[o1] : c2 ? e2[o2] : c3 ? ...)
58
- // / then return `c1 ? e1[o1 + offset] : e2[o2 + offset] : c3 ? ...`
59
- // / otherwise return an empty optionalt.
60
- optionalt<exprt>
61
- try_add_offset_to_indices (const exprt &expr, const exprt &offset);
62
-
63
57
// / Return value for `build_reference_to`; see that method for documentation.
64
58
class valuet
65
59
{
You can’t perform that action at this time.
0 commit comments