Skip to content

Commit de755e7

Browse files
authored
Merge pull request #5788 from tautschnig/forall-expr
Replace some uses of {F,f}orall_expr by ranged-for
2 parents a6a0729 + 9034596 commit de755e7

15 files changed

+51
-43
lines changed

src/analyses/goto_rw.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,11 @@ static void goto_rw(
745745
rw_set.get_objects_rec(
746746
function, target, rw_range_sett::get_modet::READ, function_call.function());
747747

748-
forall_expr(it, function_call.arguments())
748+
for(const auto &argument : function_call.arguments())
749+
{
749750
rw_set.get_objects_rec(
750-
function, target, rw_range_sett::get_modet::READ, *it);
751+
function, target, rw_range_sett::get_modet::READ, argument);
752+
}
751753
}
752754

753755
void goto_rw(

src/goto-instrument/dump_c.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,24 +1368,26 @@ void dump_ct::cleanup_expr(exprt &expr)
13681368
if(parameters.size()==arguments.size())
13691369
{
13701370
code_typet::parameterst::const_iterator it=parameters.begin();
1371-
Forall_expr(it2, arguments)
1371+
for(auto &argument : arguments)
13721372
{
13731373
const typet &type=ns.follow(it->type());
13741374
if(type.id()==ID_union &&
13751375
type.get_bool(ID_C_transparent_union))
13761376
{
1377-
if(it2->id() == ID_typecast && it2->type() == type)
1378-
*it2=to_typecast_expr(*it2).op();
1377+
if(argument.id() == ID_typecast && argument.type() == type)
1378+
argument = to_typecast_expr(argument).op();
13791379

13801380
// add a typecast for NULL or 0
1381-
if(it2->id()==ID_constant &&
1382-
(it2->is_zero() || to_constant_expr(*it2).get_value()==ID_NULL))
1381+
if(
1382+
argument.id() == ID_constant &&
1383+
(argument.is_zero() ||
1384+
to_constant_expr(argument).get_value() == ID_NULL))
13831385
{
13841386
const typet &comp_type=
13851387
to_union_type(type).components().front().type();
13861388

13871389
if(comp_type.id()==ID_pointer)
1388-
*it2=typecast_exprt(*it2, comp_type);
1390+
argument = typecast_exprt(argument, comp_type);
13891391
}
13901392
}
13911393

src/goto-instrument/goto_program2code.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,13 +1435,12 @@ void goto_program2codet::cleanup_code(
14351435

14361436
if(code.has_operands())
14371437
{
1438-
exprt::operandst &operands=code.operands();
1439-
Forall_expr(it, operands)
1438+
for(auto &op : code.operands())
14401439
{
1441-
if(it->id()==ID_code)
1442-
cleanup_code(to_code(*it), code.get_statement());
1440+
if(op.id() == ID_code)
1441+
cleanup_code(to_code(op), code.get_statement());
14431442
else
1444-
cleanup_expr(*it, false);
1443+
cleanup_expr(op, false);
14451444
}
14461445
}
14471446

@@ -1498,10 +1497,14 @@ void goto_program2codet::cleanup_function_call(
14981497
if(parameters.size()==arguments.size())
14991498
{
15001499
code_typet::parameterst::const_iterator it=parameters.begin();
1501-
Forall_expr(it2, arguments)
1500+
for(auto &argument : arguments)
15021501
{
1503-
if(it2->type().id() == ID_union || it2->type().id() == ID_union_tag)
1504-
it2->type()=it->type();
1502+
if(
1503+
argument.type().id() == ID_union ||
1504+
argument.type().id() == ID_union_tag)
1505+
{
1506+
argument.type() = it->type();
1507+
}
15051508
++it;
15061509
}
15071510
}

src/goto-instrument/value_set_fi_fp_removal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ void remove_function_pointer(
105105
if(call_type.has_ellipsis() && call_type.parameters().empty())
106106
{
107107
call_type.remove_ellipsis();
108-
forall_expr(it, code.arguments())
109-
call_type.parameters().push_back(code_typet::parametert(it->type()));
108+
for(const auto &argument : code.arguments())
109+
call_type.parameters().push_back(code_typet::parametert(argument.type()));
110110
}
111111

112112
const exprt &pointer = to_dereference_expr(function).pointer();

src/goto-programs/builtin_functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,8 @@ void goto_convertt::do_function_call_symbol(
10591059

10601060
codet fence(ID_fence);
10611061

1062-
forall_expr(it, arguments)
1063-
fence.set(get_string_constant(*it), true);
1062+
for(const auto &argument : arguments)
1063+
fence.set(get_string_constant(argument), true);
10641064

10651065
dest.add(goto_programt::make_other(fence, function.source_location()));
10661066
}

src/goto-programs/goto_convert_function_call.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ void goto_convertt::do_function_call(
5353

5454
clean_expr(new_function, dest, mode);
5555

56-
Forall_expr(it, new_arguments)
57-
clean_expr(*it, dest, mode);
56+
for(auto &new_argument : new_arguments)
57+
clean_expr(new_argument, dest, mode);
5858

5959
// split on the function
6060

src/goto-programs/goto_program.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ std::list<exprt> expressions_read(
292292
case FUNCTION_CALL:
293293
{
294294
const code_function_callt &function_call = instruction.get_function_call();
295-
forall_expr(it, function_call.arguments())
296-
dest.push_back(*it);
295+
for(const auto &argument : function_call.arguments())
296+
dest.push_back(argument);
297297
if(function_call.lhs().is_not_nil())
298298
parse_lhs_read(function_call.lhs(), dest);
299299
break;

src/goto-programs/remove_function_pointers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,10 @@ void remove_function_pointerst::remove_function_pointer(
279279
call_type.parameters().empty())
280280
{
281281
call_type.remove_ellipsis();
282-
forall_expr(it, code.arguments())
283-
call_type.parameters().push_back(
284-
code_typet::parametert(it->type()));
282+
for(const auto &argument : code.arguments())
283+
{
284+
call_type.parameters().push_back(code_typet::parametert(argument.type()));
285+
}
285286
}
286287

287288
bool found_functions;

src/goto-symex/symex_function_call.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ void goto_symext::symex_function_call_symbol(
200200

201201
code.function() = clean_expr(std::move(code.function()), state, false);
202202

203-
Forall_expr(it, code.arguments())
204-
*it = clean_expr(std::move(*it), state, false);
203+
for(auto &argument : code.arguments())
204+
argument = clean_expr(std::move(argument), state, false);
205205

206206
target.location(state.guard.as_expr(), state.source);
207207

src/solvers/flattening/boolbv_array.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ bvt boolbvt::convert_array(const exprt &expr)
3232
bvt bv;
3333
bv.reserve(width);
3434

35-
forall_expr(it, operands)
35+
for(const auto &op : operands)
3636
{
37-
const bvt &tmp = convert_bv(*it, op_width);
37+
const bvt &tmp = convert_bv(op, op_width);
3838

3939
bv.insert(bv.end(), tmp.begin(), tmp.end());
4040
}

0 commit comments

Comments
 (0)