Skip to content

Commit e1e2009

Browse files
author
Daniel Kroening
authored
Merge pull request #3738 from tautschnig/no-follow-1
Remove unnecessary ns.follow in symex_dereference [blocks: #3652]
2 parents 9a278f9 + d87e583 commit e1e2009

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/goto-symex/symex_dereference.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,14 @@ exprt goto_symext::address_arithmetic(
108108
// recursive call
109109
result=address_arithmetic(be.op(), state, guard, keep_array);
110110

111-
if(ns.follow(be.op().type()).id()==ID_array &&
112-
result.id()==ID_address_of)
111+
if(be.op().type().id() == ID_array && result.id() == ID_address_of)
113112
{
114113
address_of_exprt &a=to_address_of_expr(result);
115114

116115
// turn &a of type T[i][j] into &(a[0][0])
117-
for(const typet *t=&(ns.follow(a.type().subtype()));
118-
t->id()==ID_array && !base_type_eq(expr.type(), *t, ns);
119-
t=&(ns.follow(*t).subtype()))
116+
for(const typet *t = &(a.type().subtype());
117+
t->id() == ID_array && !base_type_eq(expr.type(), *t, ns);
118+
t = &(t->subtype()))
120119
a.object()=index_exprt(a.object(), from_integer(0, index_type()));
121120
}
122121

@@ -130,7 +129,7 @@ exprt goto_symext::address_arithmetic(
130129
result=plus_exprt(result, offset);
131130

132131
// treat &array as &array[0]
133-
const typet &expr_type=ns.follow(expr.type());
132+
const typet &expr_type = expr.type();
134133
typet dest_type_subtype;
135134

136135
if(expr_type.id()==ID_array && !keep_array)
@@ -188,7 +187,7 @@ exprt goto_symext::address_arithmetic(
188187
dereference_rec(result, state, guard, false);
189188

190189
// turn &array into &array[0]
191-
if(ns.follow(result.type()).id()==ID_array && !keep_array)
190+
if(result.type().id() == ID_array && !keep_array)
192191
result=index_exprt(result, from_integer(0, index_type()));
193192

194193
// handle field-sensitive SSA symbol
@@ -223,7 +222,7 @@ exprt goto_symext::address_arithmetic(
223222
result = address_arithmetic(tc_expr.op(), state, guard, keep_array);
224223

225224
// treat &array as &array[0]
226-
const typet &expr_type = ns.follow(expr.type());
225+
const typet &expr_type = expr.type();
227226
typet dest_type_subtype;
228227

229228
if(expr_type.id() == ID_array && !keep_array)
@@ -237,7 +236,7 @@ exprt goto_symext::address_arithmetic(
237236
throw unsupported_operation_exceptiont(
238237
"goto_symext::address_arithmetic does not handle " + expr.id_string());
239238

240-
const typet &expr_type=ns.follow(expr.type());
239+
const typet &expr_type = expr.type();
241240
INVARIANT((expr_type.id()==ID_array && !keep_array) ||
242241
base_type_eq(pointer_type(expr_type), result.type(), ns),
243242
"either non-persistent array or pointer to result");
@@ -300,10 +299,9 @@ void goto_symext::dereference_rec(
300299
// this may yield a new auto-object
301300
trigger_auto_object(expr, state);
302301
}
303-
else if(expr.id()==ID_index &&
304-
to_index_expr(expr).array().id()==ID_member &&
305-
to_array_type(ns.follow(to_index_expr(expr).array().type())).
306-
size().is_zero())
302+
else if(
303+
expr.id() == ID_index && to_index_expr(expr).array().id() == ID_member &&
304+
to_array_type(to_index_expr(expr).array().type()).size().is_zero())
307305
{
308306
// This is an expression of the form x.a[i],
309307
// where a is a zero-sized array. This gets
@@ -336,12 +334,11 @@ void goto_symext::dereference_rec(
336334

337335
exprt &object=address_of_expr.object();
338336

339-
const typet &expr_type=ns.follow(expr.type());
340337
expr = address_arithmetic(
341338
object,
342339
state,
343340
guard,
344-
to_pointer_type(expr_type).subtype().id() == ID_array);
341+
to_pointer_type(expr.type()).subtype().id() == ID_array);
345342
}
346343
else if(expr.id()==ID_typecast)
347344
{

0 commit comments

Comments
 (0)