Skip to content

Commit 088b35f

Browse files
committed
Replace uses of deprecated index_exprt constructors
This is one of the steps towards removing deprecated functions. In several cases it also isn't necessary to explicitly pass the type as it can be picked up from the first constructor argument.
1 parent 329ca12 commit 088b35f

File tree

7 files changed

+13
-40
lines changed

7 files changed

+13
-40
lines changed

src/ansi-c/c_typecast.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,7 @@ void c_typecastt::do_typecast(exprt &expr, const typet &dest_type)
720720

721721
if(src_type.id()==ID_array)
722722
{
723-
index_exprt index;
724-
index.array()=expr;
725-
index.index()=from_integer(0, index_type());
726-
index.type()=src_type.subtype();
723+
index_exprt index(expr, from_integer(0, index_type()));
727724
expr = typecast_exprt::conditional_cast(address_of_exprt(index), dest_type);
728725
return;
729726
}

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,10 +1189,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)
11891189
}
11901190
else if(op_type.id()==ID_array)
11911191
{
1192-
index_exprt index;
1193-
index.array()=op;
1194-
index.index()=from_integer(0, index_type());
1195-
index.type()=op_type.subtype();
1192+
index_exprt index(op, from_integer(0, index_type()));
11961193
op=address_of_exprt(index);
11971194
}
11981195
else if(op_type.id()==ID_empty)

src/cpp/cpp_typecheck_expr.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,9 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
262262
{
263263
// array-to-pointer conversion
264264

265-
index_exprt index1;
266-
index1.array()=expr.op1();
267-
index1.index()=from_integer(0, index_type());
268-
index1.type()=expr.op1().type().subtype();
269-
270-
index_exprt index2;
271-
index2.array()=expr.op2();
272-
index2.index()=from_integer(0, index_type());
273-
index2.type()=expr.op2().type().subtype();
265+
index_exprt index1(expr.op1(), from_integer(0, index_type()));
266+
267+
index_exprt index2(expr.op2(), from_integer(0, index_type()));
274268

275269
address_of_exprt addr1(index1);
276270
address_of_exprt addr2(index2);

src/goto-programs/string_instrumentation.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,7 @@ void string_instrumentationt::do_format_string_read(
425425

426426
if(arg_type.id()!=ID_pointer)
427427
{
428-
index_exprt index;
429-
index.array()=temp;
430-
index.index()=from_integer(0, index_type());
431-
index.type()=arg_type.subtype();
428+
index_exprt index(temp, from_integer(0, index_type()));
432429
temp=address_of_exprt(index);
433430
}
434431

@@ -474,10 +471,7 @@ void string_instrumentationt::do_format_string_read(
474471

475472
if(arg_type.id()!=ID_pointer)
476473
{
477-
index_exprt index;
478-
index.array()=temp;
479-
index.index()=from_integer(0, index_type());
480-
index.type()=arg_type.subtype();
474+
index_exprt index(temp, from_integer(0, index_type()));
481475
temp=address_of_exprt(index);
482476
}
483477

@@ -911,10 +905,8 @@ void string_instrumentationt::invalidate_buffer(
911905
bufp=buffer;
912906
else
913907
{
914-
index_exprt index;
915-
index.array()=buffer;
916-
index.index()=from_integer(0, index_type());
917-
index.type()=buf_type.subtype();
908+
index_exprt index(
909+
buffer, from_integer(0, index_type()), buf_type.subtype());
918910
bufp=address_of_exprt(index);
919911
}
920912

src/goto-symex/symex_builtin_functions.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,8 @@ void goto_symext::symex_allocate(
188188
if(object_type.id()==ID_array)
189189
{
190190
const auto &array_type = to_array_type(object_type);
191-
index_exprt index_expr(array_type.subtype());
192-
index_expr.array()=value_symbol.symbol_expr();
193-
index_expr.index()=from_integer(0, index_type());
191+
index_exprt index_expr(
192+
value_symbol.symbol_expr(), from_integer(0, index_type()));
194193
rhs = address_of_exprt(index_expr, pointer_type(array_type.subtype()));
195194
}
196195
else

src/solvers/flattening/boolbv_get.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,7 @@ exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const
337337
it1!=index_set.end();
338338
it1++)
339339
{
340-
index_exprt index;
341-
index.type()=type.subtype();
342-
index.array()=expr;
343-
index.index()=*it1;
340+
index_exprt index(expr, *it1);
344341

345342
exprt value=bv_get_cache(index);
346343
exprt index_value=bv_get_cache(*it1);

src/util/simplify_expr_array.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ bool simplify_exprt::simplify_index(exprt &expr)
8888

8989
simplify_inequality(equality_expr);
9090

91-
index_exprt new_index_expr;
92-
new_index_expr.type()=expr.type();
93-
new_index_expr.array()=with_expr.op0();
94-
new_index_expr.index()=expr.op1();
91+
index_exprt new_index_expr(with_expr.op0(), expr.op1(), expr.type());
9592

9693
simplify_index(new_index_expr); // recursive call
9794

0 commit comments

Comments
 (0)