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(
9999 return json_result;
100100}
101101
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)
105107{
106108 if (const auto *index_expr = expr_try_dynamic_cast<index_exprt>(expr))
107109 {
@@ -123,6 +125,13 @@ optionalt<exprt> value_set_dereferencet::try_add_offset_to_indices(
123125 return {};
124126 return if_exprt{if_expr->cond (), *true_case, *false_case};
125127 }
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+ }
126135 else
127136 {
128137 return {};
Original file line number Diff line number Diff line change @@ -54,12 +54,6 @@ class value_set_dereferencet final
5454 // / \param display_points_to_sets: Display size and contents of points to sets
5555 exprt dereference (const exprt &pointer, bool display_points_to_sets = false );
5656
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-
6357 // / Return value for `build_reference_to`; see that method for documentation.
6458 class valuet
6559 {
You can’t perform that action at this time.
0 commit comments