Skip to content

Commit 6461a1f

Browse files
author
Daniel Kroening
committed
strengthen typing of array_exprt::type
The class invariant that array expressions have array type is now enforced.
1 parent e5d1640 commit 6461a1f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/analyses/goto_rw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void rw_range_sett::get_objects_array(
300300
const range_spect &range_start,
301301
const range_spect &size)
302302
{
303-
const array_typet &array_type = to_array_type(expr.type());
303+
const array_typet &array_type = expr.type();
304304

305305
auto subtype_bits = pointer_offset_bits(array_type.subtype(), ns);
306306

src/util/expr_initializer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ optionalt<exprt> expr_initializert<nondet>::expr_initializer_rec(
122122
// we initialize this with an empty array
123123

124124
array_exprt value({}, array_type);
125-
value.type().id(ID_array);
126-
value.type().set(ID_size, from_integer(0, size_type()));
125+
value.type().size() = from_integer(0, size_type());
127126
value.add_source_location()=source_location;
128127
return std::move(value);
129128
}

src/util/std_expr.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,16 @@ class array_exprt : public multi_ary_exprt
16811681
: multi_ary_exprt(ID_array, std::move(_operands), _type)
16821682
{
16831683
}
1684+
1685+
const array_typet &type() const
1686+
{
1687+
return static_cast<const array_typet &>(multi_ary_exprt::type());
1688+
}
1689+
1690+
array_typet &type()
1691+
{
1692+
return static_cast<array_typet &>(multi_ary_exprt::type());
1693+
}
16841694
};
16851695

16861696
template <>

0 commit comments

Comments
 (0)