Skip to content

Commit 5592a6d

Browse files
committed
Remove unnecessary use of ns.follow in analyses/
Only structs, unions, enums can be hidden behind tags.
1 parent b03eb7a commit 5592a6d

File tree

5 files changed

+25
-28
lines changed

5 files changed

+25
-28
lines changed

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void custom_bitvector_domaint::assign_struct_rec(
230230
custom_bitvector_analysist &cba,
231231
const namespacet &ns)
232232
{
233-
if(ns.follow(lhs.type()).id()==ID_struct)
233+
if(lhs.type().id() == ID_struct || lhs.type().id() == ID_struct_tag)
234234
{
235235
const struct_typet &struct_type=
236236
to_struct_type(ns.follow(lhs.type()));

src/analyses/goto_check.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ void goto_checkt::undefined_shift_check(
264264
// Undefined for all types and shifts if distance exceeds width,
265265
// and also undefined for negative distances.
266266

267-
const typet &distance_type=
268-
ns.follow(expr.distance().type());
267+
const typet &distance_type = expr.distance().type();
269268

270269
if(distance_type.id()==ID_signedbv)
271270
{
@@ -281,8 +280,7 @@ void goto_checkt::undefined_shift_check(
281280
guard);
282281
}
283282

284-
const typet &op_type=
285-
ns.follow(expr.op().type());
283+
const typet &op_type = expr.op().type();
286284

287285
if(op_type.id()==ID_unsignedbv || op_type.id()==ID_signedbv)
288286
{
@@ -390,7 +388,7 @@ void goto_checkt::conversion_check(
390388
return;
391389

392390
// First, check type.
393-
const typet &type=ns.follow(expr.type());
391+
const typet &type = expr.type();
394392

395393
if(type.id()!=ID_signedbv &&
396394
type.id()!=ID_unsignedbv)
@@ -403,7 +401,7 @@ void goto_checkt::conversion_check(
403401
if(expr.operands().size()!=1)
404402
throw "typecast takes one operand";
405403

406-
const typet &old_type=ns.follow(expr.op0().type());
404+
const typet &old_type = expr.op0().type();
407405

408406
if(type.id()==ID_signedbv)
409407
{
@@ -563,7 +561,7 @@ void goto_checkt::integer_overflow_check(
563561
return;
564562

565563
// First, check type.
566-
const typet &type=ns.follow(expr.type());
564+
const typet &type = expr.type();
567565

568566
if(type.id()==ID_signedbv && !enable_signed_overflow_check)
569567
return;
@@ -781,7 +779,7 @@ void goto_checkt::float_overflow_check(
781779
return;
782780

783781
// First, check type.
784-
const typet &type=ns.follow(expr.type());
782+
const typet &type = expr.type();
785783

786784
if(type.id()!=ID_floatbv)
787785
return;
@@ -794,7 +792,7 @@ void goto_checkt::float_overflow_check(
794792
// to smaller type.
795793
assert(expr.operands().size()==1);
796794

797-
if(ns.follow(expr.op0().type()).id()==ID_floatbv)
795+
if(expr.op0().type().id() == ID_floatbv)
798796
{
799797
// float-to-float
800798
const isinf_exprt op0_inf(expr.op0());
@@ -1229,7 +1227,7 @@ void goto_checkt::bounds_check(
12291227
!expr.get_bool("bounds_check"))
12301228
return;
12311229

1232-
typet array_type=ns.follow(expr.array().type());
1230+
typet array_type = expr.array().type();
12331231

12341232
if(array_type.id()==ID_pointer)
12351233
throw "index got pointer as array type";

src/analyses/goto_rw.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,15 @@ void rw_range_sett::get_objects_member(
222222
const range_spect &range_start,
223223
const range_spect &size)
224224
{
225-
const typet &type=ns.follow(expr.struct_op().type());
225+
const typet &type = expr.struct_op().type();
226226

227-
if(type.id()==ID_union ||
228-
range_start==-1)
227+
if(type.id() == ID_union || type.id() == ID_union_tag || range_start == -1)
229228
{
230229
get_objects_rec(mode, expr.struct_op(), range_start, size);
231230
return;
232231
}
233232

234-
const struct_typet &struct_type=to_struct_type(type);
233+
const struct_typet &struct_type = to_struct_type(ns.follow(type));
235234

236235
auto offset_bits =
237236
member_offset_bits(struct_type, expr.get_component_name(), ns);
@@ -259,7 +258,7 @@ void rw_range_sett::get_objects_index(
259258
return;
260259

261260
range_spect sub_size=0;
262-
const typet &type=ns.follow(expr.array().type());
261+
const typet &type = expr.array().type();
263262

264263
if(type.id()==ID_vector)
265264
{
@@ -302,8 +301,7 @@ void rw_range_sett::get_objects_array(
302301
const range_spect &range_start,
303302
const range_spect &size)
304303
{
305-
const array_typet &array_type=
306-
to_array_type(ns.follow(expr.type()));
304+
const array_typet &array_type = to_array_type(expr.type());
307305

308306
auto subtype_bits = pointer_offset_bits(array_type.subtype(), ns);
309307

src/analyses/invariant_propagation.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ void invariant_propagationt::get_objects_rec(
9090
const exprt &src,
9191
std::list<exprt> &dest)
9292
{
93-
const typet &t=ns.follow(src.type());
93+
const typet &t = src.type();
9494

95-
if(t.id()==ID_struct ||
96-
t.id()==ID_union)
95+
if(
96+
t.id() == ID_struct || t.id() == ID_union || t.id() == ID_struct_tag ||
97+
t.id() == ID_union_tag)
9798
{
98-
const struct_typet &struct_type=to_struct_type(t);
99+
const struct_union_typet &struct_type = to_struct_union_type(ns.follow(t));
99100

100101
for(const auto &component : struct_type.components())
101102
{
@@ -184,8 +185,9 @@ bool invariant_propagationt::check_type(const typet &type) const
184185
{
185186
if(type.id()==ID_pointer)
186187
return true;
187-
else if(type.id()==ID_struct ||
188-
type.id()==ID_union)
188+
else if(
189+
type.id() == ID_struct || type.id() == ID_union ||
190+
type.id() == ID_struct_tag || type.id() == ID_union_tag)
189191
return false;
190192
else if(type.id()==ID_array)
191193
return false;

src/analyses/invariant_set.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,11 @@ void invariant_sett::strengthen_rec(const exprt &expr)
486486
{
487487
const auto &equal_expr = to_equal_expr(expr);
488488

489-
const typet &op_type = ns->follow(equal_expr.op0().type());
489+
const typet &op_type = equal_expr.op0().type();
490490

491-
if(op_type.id()==ID_struct)
491+
if(op_type.id() == ID_struct || op_type.id() == ID_struct_tag)
492492
{
493-
const struct_typet &struct_type=to_struct_type(op_type);
494-
493+
const struct_typet &struct_type = to_struct_type(ns->follow(op_type));
495494

496495
for(const auto &comp : struct_type.components())
497496
{

0 commit comments

Comments
 (0)