Skip to content

Commit 6eb9142

Browse files
committed
Remove unnecessary use of ns.follow in goto-programs/
Only structs, unions, enums can be hidden behind tags.
1 parent b03eb7a commit 6eb9142

10 files changed

+17
-21
lines changed

src/goto-programs/builtin_functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ exprt goto_convertt::get_array_argument(const exprt &src)
576576

577577
assert(src.op0().operands().size()==2);
578578

579-
if(ns.follow(src.op0().op0().type()).id()!=ID_array)
579+
if(src.op0().op0().type().id() != ID_array)
580580
{
581581
error().source_location=src.find_source_location();
582582
error() << "expected array as argument" << eom;
@@ -1188,7 +1188,7 @@ void goto_convertt::do_function_call_symbol(
11881188
}
11891189

11901190
// our __builtin_va_list is a pointer
1191-
if(ns.follow(dest_expr.type()).id()==ID_pointer)
1191+
if(dest_expr.type().id() == ID_pointer)
11921192
{
11931193
goto_programt::targett t=dest.add_instruction(ASSIGN);
11941194
t->source_location=function.source_location();

src/goto-programs/goto_convert_side_effect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void goto_convertt::remove_assignment(
9696

9797
exprt rhs;
9898

99-
const typet &op0_type=ns.follow(expr.op0().type());
99+
const typet &op0_type = expr.op0().type();
100100

101101
if(op0_type.id()==ID_c_bool)
102102
{
@@ -168,7 +168,7 @@ void goto_convertt::remove_pre(
168168
else
169169
rhs.id(ID_minus);
170170

171-
const typet &op_type=ns.follow(expr.op0().type());
171+
const typet &op_type = expr.op0().type();
172172

173173
if(op_type.id()==ID_bool)
174174
{
@@ -257,7 +257,7 @@ void goto_convertt::remove_post(
257257
else
258258
rhs.id(ID_minus);
259259

260-
const typet &op_type=ns.follow(expr.op0().type());
260+
const typet &op_type = expr.op0().type();
261261

262262
if(op_type.id()==ID_bool)
263263
{

src/goto-programs/goto_inline_class.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void goto_inlinet::parameter_assignments(
5050
for(const auto &parameter : parameter_types)
5151
{
5252
// this is the type the n-th argument should be
53-
const typet &par_type=ns.follow(parameter.type());
53+
const typet &par_type = parameter.type();
5454

5555
const irep_idt &identifier=parameter.get_identifier();
5656

@@ -95,8 +95,8 @@ void goto_inlinet::parameter_assignments(
9595
// subject to some exceptions
9696
if(!base_type_eq(par_type, actual.type(), ns))
9797
{
98-
const typet &f_partype=ns.follow(par_type);
99-
const typet &f_acttype=ns.follow(actual.type());
98+
const typet &f_partype = par_type;
99+
const typet &f_acttype = actual.type();
100100

101101
// we are willing to do some conversion
102102
if((f_partype.id()==ID_pointer &&

src/goto-programs/goto_trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ std::string trace_numeric_value(
183183
const namespacet &ns,
184184
const trace_optionst &options)
185185
{
186-
const typet &type=ns.follow(expr.type());
186+
const typet &type = expr.type();
187187

188188
if(expr.id()==ID_constant)
189189
{

src/goto-programs/graphml_witness.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ std::string graphml_witnesst::convert_assign_rec(
5656

5757
if(assign.rhs().id()==ID_array)
5858
{
59-
const array_typet &type=
60-
to_array_type(ns.follow(assign.rhs().type()));
59+
const array_typet &type = to_array_type(assign.rhs().type());
6160

6261
unsigned i=0;
6362
forall_operands(it, assign.rhs())

src/goto-programs/interpreter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,9 @@ exprt interpretert::get_value(
618618
if(offset_from_address == 0)
619619
return address_of_exprt(symbol_expr);
620620

621-
if(ns.follow(type_from_identifier).id() == ID_struct)
621+
if(
622+
type_from_identifier.id() == ID_struct ||
623+
type_from_identifier.id() == ID_struct_tag)
622624
{
623625
const auto c = get_component(identifier, offset_from_address);
624626
member_exprt member_expr(symbol_expr, c);

src/goto-programs/remove_function_pointers.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ bool remove_function_pointerst::is_type_compatible(
202202
void remove_function_pointerst::fix_argument_types(
203203
code_function_callt &function_call)
204204
{
205-
const code_typet &code_type=
206-
to_code_type(ns.follow(function_call.function().type()));
205+
const code_typet &code_type = to_code_type(function_call.function().type());
207206

208207
const code_typet::parameterst &function_parameters=
209208
code_type.parameters();
@@ -232,8 +231,7 @@ void remove_function_pointerst::fix_return_type(
232231
if(function_call.lhs().is_nil())
233232
return;
234233

235-
const code_typet &code_type=
236-
to_code_type(ns.follow(function_call.function().type()));
234+
const code_typet &code_type = to_code_type(function_call.function().type());
237235

238236
// type already ok?
239237
if(type_eq(

src/goto-programs/string_abstraction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ goto_programt::targett string_abstractiont::abstract_assign(
523523
if(has_string_macros(rhs))
524524
replace_string_macros(rhs, false, target->source_location);
525525

526-
const typet &type=ns.follow(lhs.type());
526+
const typet &type = lhs.type();
527527
if(type.id()==ID_pointer || type.id()==ID_array)
528528
return abstract_pointer_assign(dest, target);
529529
else if(is_char_type(type))

src/goto-programs/string_abstraction.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ class string_abstractiont:public messaget
5252

5353
bool is_char_type(const typet &type) const
5454
{
55-
if(type.id() == ID_struct_tag)
56-
return is_char_type(ns.follow(type));
57-
5855
if(type.id()!=ID_signedbv &&
5956
type.id()!=ID_unsignedbv)
6057
return false;

src/goto-programs/vcd_goto_trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ std::string as_vcd_binary(
2323
const exprt &expr,
2424
const namespacet &ns)
2525
{
26-
const typet &type=ns.follow(expr.type());
26+
const typet &type = expr.type();
2727

2828
if(expr.id()==ID_constant)
2929
{

0 commit comments

Comments
 (0)