Skip to content

Commit 18ff683

Browse files
committed
Remove unnecessary use of ns.follow
Further cleanup of some remaining unnecessary ns.follow calls after the earlier removal of ns.follow in these directories.
1 parent e5186ad commit 18ff683

File tree

10 files changed

+58
-56
lines changed

10 files changed

+58
-56
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2875,7 +2875,7 @@ void c_typecheck_baset::typecheck_expr_unary_arithmetic(exprt &expr)
28752875

28762876
if(o_type.id()==ID_vector)
28772877
{
2878-
if(is_number(follow(o_type.subtype())))
2878+
if(is_number(o_type.subtype()))
28792879
{
28802880
// Vector arithmetic.
28812881
expr.type()=operand.type();

src/cpp/cpp_typecheck_expr.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ void cpp_typecheckt::typecheck_expr_main(exprt &expr)
121121
// these appear to have type "struct _GUID"
122122
// and they are lvalues!
123123
expr.type() = struct_tag_typet("tag-_GUID");
124-
follow(expr.type());
125124
expr.set(ID_C_lvalue, true);
126125
}
127126
else if(expr.id()==ID_noexcept)
@@ -415,15 +414,18 @@ bool cpp_typecheckt::overloadable(const exprt &expr)
415414

416415
forall_operands(it, expr)
417416
{
418-
typet t=follow(it->type());
417+
typet t = it->type();
419418

420419
if(is_reference(t))
421420
t=t.subtype();
422421

423-
if(t.id()==ID_struct ||
424-
t.id()==ID_union ||
425-
t.id()==ID_c_enum || t.id() == ID_c_enum_tag)
422+
if(
423+
t.id() == ID_struct || t.id() == ID_union || t.id() == ID_c_enum ||
424+
t.id() == ID_c_enum_tag || t.id() == ID_struct_tag ||
425+
t.id() == ID_union_tag)
426+
{
426427
return true;
428+
}
427429
}
428430

429431
return false;

src/goto-instrument/dump_c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ void dump_ct::convert_compound(
414414

415415
for(const auto &comp : type.components())
416416
{
417-
const typet &comp_type=ns.follow(comp.type());
417+
const typet &comp_type = comp.type();
418418

419419
if(comp_type.id()==ID_code ||
420420
comp.get_bool(ID_from_base) ||

src/goto-programs/string_instrumentation.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ void string_instrumentationt::do_format_string_read(
410410
if(token.type==format_tokent::token_typet::STRING)
411411
{
412412
const exprt &arg=arguments[argument_start_inx+args];
413-
const typet &arg_type=ns.follow(arg.type());
414413

415414
if(arg.id()!=ID_string_constant) // we don't need to check constants
416415
{
@@ -423,7 +422,7 @@ void string_instrumentationt::do_format_string_read(
423422

424423
exprt temp(arg);
425424

426-
if(arg_type.id()!=ID_pointer)
425+
if(arg.type().id() != ID_pointer)
427426
{
428427
index_exprt index(temp, from_integer(0, index_type()));
429428
temp=address_of_exprt(index);
@@ -456,10 +455,8 @@ void string_instrumentationt::do_format_string_read(
456455
for(std::size_t i=2; i<arguments.size(); i++)
457456
{
458457
const exprt &arg=arguments[i];
459-
const typet &arg_type=ns.follow(arguments[i].type());
460458

461-
if(arguments[i].id()!=ID_string_constant &&
462-
is_string_type(arg_type))
459+
if(arguments[i].id() != ID_string_constant && is_string_type(arg.type()))
463460
{
464461
goto_programt::targett assertion=dest.add_instruction();
465462
assertion->source_location=target->source_location;
@@ -469,7 +466,7 @@ void string_instrumentationt::do_format_string_read(
469466

470467
exprt temp(arg);
471468

472-
if(arg_type.id()!=ID_pointer)
469+
if(arg.type().id() != ID_pointer)
473470
{
474471
index_exprt index(temp, from_integer(0, index_type()));
475472
temp=address_of_exprt(index);
@@ -514,7 +511,7 @@ void string_instrumentationt::do_format_string_write(
514511
case format_tokent::token_typet::STRING:
515512
{
516513
const exprt &argument=arguments[argument_start_inx+args];
517-
const typet &arg_type=ns.follow(argument.type());
514+
const typet &arg_type = argument.type();
518515

519516
goto_programt::targett assertion=dest.add_instruction();
520517
assertion->source_location=target->source_location;
@@ -566,7 +563,7 @@ void string_instrumentationt::do_format_string_write(
566563
default: // everything else
567564
{
568565
const exprt &argument=arguments[argument_start_inx+args];
569-
const typet &arg_type=ns.follow(argument.type());
566+
const typet &arg_type = argument.type();
570567

571568
goto_programt::targett assignment=dest.add_instruction(ASSIGN);
572569
assignment->source_location=target->source_location;
@@ -587,7 +584,7 @@ void string_instrumentationt::do_format_string_write(
587584
{
588585
for(std::size_t i=argument_start_inx; i<arguments.size(); i++)
589586
{
590-
const typet &arg_type=ns.follow(arguments[i].type());
587+
const typet &arg_type = arguments[i].type();
591588

592589
// Note: is_string_type() is a `good guess' here. Actually
593590
// any of the pointers could point into an array. But it

src/goto-symex/symex_assign.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ void goto_symext::symex_assign_rec(
145145
state, to_index_expr(lhs), full_lhs, rhs, guard, assignment_type);
146146
else if(lhs.id()==ID_member)
147147
{
148-
const typet &type=ns.follow(to_member_expr(lhs).struct_op().type());
149-
if(type.id()==ID_struct)
148+
const typet &type = to_member_expr(lhs).struct_op().type();
149+
if(type.id() == ID_struct || type.id() == ID_struct_tag)
150150
symex_assign_struct_member(
151151
state, to_member_expr(lhs), full_lhs, rhs, guard, assignment_type);
152-
else if(type.id()==ID_union)
152+
else if(type.id() == ID_union || type.id() == ID_union_tag)
153153
{
154154
// should have been replaced by byte_extract
155155
throw unsupported_operation_exceptiont(

src/goto-symex/symex_function_call.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,27 @@ void goto_symext::parameter_assignments(
8686
// It should be the same exact type.
8787
if(!base_type_eq(parameter_type, rhs.type(), ns))
8888
{
89-
const typet &f_parameter_type=ns.follow(parameter_type);
90-
const typet &f_rhs_type=ns.follow(rhs.type());
89+
const typet &rhs_type = rhs.type();
9190

9291
// But we are willing to do some limited conversion.
9392
// This is highly dubious, obviously.
94-
if((f_parameter_type.id()==ID_signedbv ||
95-
f_parameter_type.id()==ID_unsignedbv ||
96-
f_parameter_type.id()==ID_c_enum_tag ||
97-
f_parameter_type.id()==ID_bool ||
98-
f_parameter_type.id()==ID_pointer ||
99-
f_parameter_type.id()==ID_union) &&
100-
(f_rhs_type.id()==ID_signedbv ||
101-
f_rhs_type.id()==ID_unsignedbv ||
102-
f_rhs_type.id()==ID_c_bit_field ||
103-
f_rhs_type.id()==ID_c_enum_tag ||
104-
f_rhs_type.id()==ID_bool ||
105-
f_rhs_type.id()==ID_pointer ||
106-
f_rhs_type.id()==ID_union))
93+
// clang-format off
94+
if(
95+
(parameter_type.id() == ID_signedbv ||
96+
parameter_type.id() == ID_unsignedbv ||
97+
parameter_type.id() == ID_c_enum_tag ||
98+
parameter_type.id() == ID_bool ||
99+
parameter_type.id() == ID_pointer ||
100+
parameter_type.id() == ID_union ||
101+
parameter_type.id() == ID_union_tag) &&
102+
(rhs_type.id() == ID_signedbv ||
103+
rhs_type.id() == ID_unsignedbv ||
104+
rhs_type.id() == ID_c_bit_field ||
105+
rhs_type.id() == ID_c_enum_tag ||
106+
rhs_type.id() == ID_bool ||
107+
rhs_type.id() == ID_pointer ||
108+
rhs_type.id() == ID_union ||
109+
rhs_type.id() == ID_union_tag))
107110
{
108111
rhs=
109112
byte_extract_exprt(
@@ -120,6 +123,7 @@ void goto_symext::parameter_assignments(
120123
<< ", expected " << parameter_type.pretty();
121124
throw unsupported_operation_exceptiont(error.str());
122125
}
126+
// clang-format on
123127
}
124128

125129
assignment_typet assignment_type;

src/pointer-analysis/value_set_dereference.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to(
391391
result.pointer_guard=same_object(pointer_expr, object_pointer);
392392
}
393393

394-
const typet &object_type=ns.follow(object.type());
395-
const typet &root_object_type=ns.follow(root_object.type());
394+
const typet &object_type = object.type();
395+
const typet &root_object_type = root_object.type();
396396

397397
exprt root_object_subexpression=root_object;
398398

@@ -402,10 +402,7 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to(
402402
// The simplest case: types match, and offset is zero!
403403
// This is great, we are almost done.
404404

405-
result.value=object;
406-
407-
if(object_type!=ns.follow(dereference_type))
408-
result.value.make_typecast(dereference_type);
405+
result.value = typecast_exprt::conditional_cast(object, dereference_type);
409406
}
410407
else if(root_object_type.id()==ID_array &&
411408
dereference_type_compare(
@@ -582,19 +579,18 @@ bool value_set_dereferencet::memory_model_bytes(
582579

583580
// See if we have an array of bytes already,
584581
// and we want something byte-sized.
585-
auto from_type_subtype_size =
586-
pointer_offset_size(ns.follow(from_type).subtype(), ns);
582+
auto from_type_subtype_size = pointer_offset_size(from_type.subtype(), ns);
587583

588584
auto to_type_size = pointer_offset_size(to_type, ns);
589585

590586
if(
591587
from_type.id() == ID_array && from_type_subtype_size.has_value() &&
592588
*from_type_subtype_size == 1 && to_type_size.has_value() &&
593-
*to_type_size == 1 && is_a_bv_type(ns.follow(from_type).subtype()) &&
589+
*to_type_size == 1 && is_a_bv_type(from_type.subtype()) &&
594590
is_a_bv_type(to_type))
595591
{
596592
// yes, can use 'index'
597-
result=index_exprt(value, offset, ns.follow(from_type).subtype());
593+
result = index_exprt(value, offset, from_type.subtype());
598594

599595
// possibly need to convert
600596
if(!base_type_eq(result.type(), to_type, ns))

src/pointer-analysis/value_set_fi.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -909,13 +909,14 @@ void value_set_fit::get_reference_set_sharing_rec(
909909
forall_objects(it, struct_references.read())
910910
{
911911
const exprt &object=object_numbering[it->first];
912-
const typet &obj_type=ns.follow(object.type());
912+
const typet &obj_type = object.type();
913913

914914
if(object.id()==ID_unknown)
915915
insert(dest, exprt(ID_unknown, expr.type()));
916-
else if(object.id()==ID_dynamic_object &&
917-
obj_type.id()!=ID_struct &&
918-
obj_type.id()!=ID_union)
916+
else if(
917+
object.id() == ID_dynamic_object && obj_type.id() != ID_struct &&
918+
obj_type.id() != ID_union && obj_type.id() != ID_struct_tag &&
919+
obj_type.id() != ID_union_tag)
919920
{
920921
// we catch dynamic objects of the wrong type,
921922
// to avoid non-integral typecasts.

src/pointer-analysis/value_set_fivr.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,13 +1022,14 @@ void value_set_fivrt::get_reference_set_sharing_rec(
10221022
forall_objects(it, object_map)
10231023
{
10241024
const exprt &object=object_numbering[it->first];
1025-
const typet &obj_type=ns.follow(object.type());
1025+
const typet &obj_type = object.type();
10261026

10271027
if(object.id()==ID_unknown)
10281028
insert_from(dest, exprt(ID_unknown, expr.type()));
1029-
else if(object.id()==ID_dynamic_object &&
1030-
obj_type.id()!=ID_struct &&
1031-
obj_type.id()!=ID_union)
1029+
else if(
1030+
object.id() == ID_dynamic_object && obj_type.id() != ID_struct &&
1031+
obj_type.id() != ID_union && obj_type.id() != ID_struct_tag &&
1032+
obj_type.id() != ID_union_tag)
10321033
{
10331034
// we catch dynamic objects of the wrong type,
10341035
// to avoid non-integral typecasts.

src/pointer-analysis/value_set_fivrns.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,13 +715,14 @@ void value_set_fivrnst::get_reference_set_rec(
715715
forall_objects(it, object_map)
716716
{
717717
const exprt &object=object_numbering[it->first];
718-
const typet &obj_type=ns.follow(object.type());
718+
const typet &obj_type = object.type();
719719

720720
if(object.id()==ID_unknown)
721721
insert_from(dest, exprt(ID_unknown, expr.type()));
722-
else if(object.id()==ID_dynamic_object &&
723-
obj_type.id()!=ID_struct &&
724-
obj_type.id()!=ID_union)
722+
else if(
723+
object.id() == ID_dynamic_object && obj_type.id() != ID_struct &&
724+
obj_type.id() != ID_union && obj_type.id() != ID_struct_tag &&
725+
obj_type.id() != ID_union_tag)
725726
{
726727
// we catch dynamic objects of the wrong type,
727728
// to avoid non-integral typecasts.

0 commit comments

Comments
 (0)