Skip to content

Commit 261f598

Browse files
authored
Merge pull request #5789 from tautschnig/forall-goto_program_instructions
Replace some uses of {f,F}orall_goto_program_instructions by ranged-for
2 parents 76f37ce + 0a1cf96 commit 261f598

34 files changed

+215
-190
lines changed

jbmc/src/java_bytecode/remove_exceptions.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,17 @@ symbol_exprt remove_exceptionst::get_inflight_exception_global()
190190
bool remove_exceptionst::function_or_callees_may_throw(
191191
const goto_programt &goto_program) const
192192
{
193-
forall_goto_program_instructions(instr_it, goto_program)
193+
for(const auto &instruction : goto_program.instructions)
194194
{
195-
if(instr_it->is_throw())
195+
if(instruction.is_throw())
196196
{
197197
return true;
198198
}
199199

200-
if(instr_it->is_function_call())
200+
if(instruction.is_function_call())
201201
{
202-
const exprt &function_expr=
203-
to_code_function_call(instr_it->code).function();
202+
const exprt &function_expr =
203+
to_code_function_call(instruction.code).function();
204204
DATA_INVARIANT(
205205
function_expr.id()==ID_symbol,
206206
"identifier expected to be a symbol");

src/analyses/goto_check.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ void goto_checkt::collect_allocations(
290290
return;
291291

292292
forall_goto_functions(itf, goto_functions)
293-
forall_goto_program_instructions(it, itf->second.body)
293+
{
294+
for(const auto &instruction : itf->second.body.instructions)
294295
{
295-
const goto_programt::instructiont &instruction=*it;
296296
if(!instruction.is_function_call())
297297
continue;
298298

@@ -313,6 +313,7 @@ void goto_checkt::collect_allocations(
313313
assert(args[0].type()==args[1].type());
314314
allocations.push_back({args[0], args[1]});
315315
}
316+
}
316317
}
317318

318319
void goto_checkt::invalidate(const exprt &lhs)
@@ -2092,28 +2093,33 @@ void goto_checkt::goto_check(
20922093
}
20932094
}
20942095

2095-
Forall_goto_program_instructions(i_it, new_code)
2096+
for(auto &instruction : new_code.instructions)
20962097
{
2097-
if(i_it->source_location.is_nil())
2098+
if(instruction.source_location.is_nil())
20982099
{
2099-
i_it->source_location.id(irep_idt());
2100+
instruction.source_location.id(irep_idt());
21002101

21012102
if(!it->source_location.get_file().empty())
2102-
i_it->source_location.set_file(it->source_location.get_file());
2103+
instruction.source_location.set_file(it->source_location.get_file());
21032104

21042105
if(!it->source_location.get_line().empty())
2105-
i_it->source_location.set_line(it->source_location.get_line());
2106+
instruction.source_location.set_line(it->source_location.get_line());
21062107

21072108
if(!it->source_location.get_function().empty())
2108-
i_it->source_location.set_function(
2109+
instruction.source_location.set_function(
21092110
it->source_location.get_function());
21102111

21112112
if(!it->source_location.get_column().empty())
2112-
i_it->source_location.set_column(it->source_location.get_column());
2113+
{
2114+
instruction.source_location.set_column(
2115+
it->source_location.get_column());
2116+
}
21132117

21142118
if(!it->source_location.get_java_bytecode_index().empty())
2115-
i_it->source_location.set_java_bytecode_index(
2119+
{
2120+
instruction.source_location.set_java_bytecode_index(
21162121
it->source_location.get_java_bytecode_index());
2122+
}
21172123
}
21182124
}
21192125

src/analyses/local_bitvector_analysis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ void local_bitvector_analysist::output(
363363
{
364364
unsigned l=0;
365365

366-
forall_goto_program_instructions(i_it, goto_function.body)
366+
for(const auto &instruction : goto_function.body.instructions)
367367
{
368-
out << "**** " << i_it->source_location << "\n";
368+
out << "**** " << instruction.source_location << "\n";
369369

370370
const auto &loc_info=loc_infos[l];
371371

@@ -381,7 +381,7 @@ void local_bitvector_analysist::output(
381381
}
382382

383383
out << "\n";
384-
goto_function.body.output_instruction(ns, irep_idt(), out, *i_it);
384+
goto_function.body.output_instruction(ns, irep_idt(), out, instruction);
385385
out << "\n";
386386

387387
l++;

src/analyses/local_may_alias.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,9 @@ void local_may_aliast::output(
474474
{
475475
unsigned l=0;
476476

477-
forall_goto_program_instructions(i_it, goto_function.body)
477+
for(const auto &instruction : goto_function.body.instructions)
478478
{
479-
out << "**** " << i_it->source_location << "\n";
479+
out << "**** " << instruction.source_location << "\n";
480480

481481
const loc_infot &loc_info=loc_infos[l];
482482

@@ -502,7 +502,7 @@ void local_may_aliast::output(
502502
}
503503

504504
out << "\n";
505-
goto_function.body.output_instruction(ns, irep_idt(), out, *i_it);
505+
goto_function.body.output_instruction(ns, irep_idt(), out, instruction);
506506
out << "\n";
507507

508508
l++;

src/analyses/local_safe_pointers.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ void local_safe_pointerst::output(
191191
const goto_programt &goto_program,
192192
const namespacet &ns)
193193
{
194-
forall_goto_program_instructions(i_it, goto_program)
194+
for(const auto &instruction : goto_program.instructions)
195195
{
196-
out << "**** " << i_it->location_number << " "
197-
<< i_it->source_location << "\n";
196+
out << "**** " << instruction.location_number << " "
197+
<< instruction.source_location << "\n";
198198

199199
out << "Non-null expressions: ";
200200

201-
auto findit = non_null_expressions.find(i_it->location_number);
201+
auto findit = non_null_expressions.find(instruction.location_number);
202202
if(findit == non_null_expressions.end())
203203
out << "{}";
204204
else
@@ -216,7 +216,7 @@ void local_safe_pointerst::output(
216216
}
217217

218218
out << '\n';
219-
goto_program.output_instruction(ns, irep_idt(), out, *i_it);
219+
goto_program.output_instruction(ns, irep_idt(), out, instruction);
220220
out << '\n';
221221
}
222222
}
@@ -235,21 +235,21 @@ void local_safe_pointerst::output_safe_dereferences(
235235
const goto_programt &goto_program,
236236
const namespacet &ns)
237237
{
238-
forall_goto_program_instructions(i_it, goto_program)
238+
for(const auto &instruction : goto_program.instructions)
239239
{
240-
out << "**** " << i_it->location_number << " "
241-
<< i_it->source_location << "\n";
240+
out << "**** " << instruction.location_number << " "
241+
<< instruction.source_location << "\n";
242242

243243
out << "Safe (known-not-null) dereferences: ";
244244

245-
auto findit = non_null_expressions.find(i_it->location_number);
245+
auto findit = non_null_expressions.find(instruction.location_number);
246246
if(findit == non_null_expressions.end())
247247
out << "{}";
248248
else
249249
{
250250
out << "{";
251251
bool first = true;
252-
i_it->apply([&first, &out](const exprt &e) {
252+
instruction.apply([&first, &out](const exprt &e) {
253253
for(auto subexpr_it = e.depth_begin(), subexpr_end = e.depth_end();
254254
subexpr_it != subexpr_end;
255255
++subexpr_it)
@@ -267,7 +267,7 @@ void local_safe_pointerst::output_safe_dereferences(
267267
}
268268

269269
out << '\n';
270-
goto_program.output_instruction(ns, irep_idt(), out, *i_it);
270+
goto_program.output_instruction(ns, irep_idt(), out, instruction);
271271
out << '\n';
272272
}
273273
}

src/analyses/locals.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Date: March 2013
1717

1818
void localst::build(const goto_functiont &goto_function)
1919
{
20-
forall_goto_program_instructions(it, goto_function.body)
20+
for(const auto &instruction : goto_function.body.instructions)
2121
{
22-
if(it->is_decl())
23-
locals.insert(it->get_decl().get_identifier());
22+
if(instruction.is_decl())
23+
locals.insert(instruction.get_decl().get_identifier());
2424
}
2525

2626
locals.insert(

src/goto-cc/linker_script_merge.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,10 @@ int linker_script_merget::pointerize_linker_defined_symbols(
259259
for(auto &gf : goto_model.goto_functions.function_map)
260260
{
261261
goto_programt &program=gf.second.body;
262-
Forall_goto_program_instructions(iit, program)
262+
for(auto &instruction : program.instructions)
263263
{
264-
for(exprt *insts : std::list<exprt *>({&(iit->code), &(iit->guard)}))
264+
for(exprt *insts :
265+
std::list<exprt *>({&(instruction.code), &(instruction.guard)}))
265266
{
266267
std::list<symbol_exprt> to_pointerize;
267268
symbols_to_pointerize(linker_values, *insts, to_pointerize);
@@ -277,7 +278,7 @@ int linker_script_merget::pointerize_linker_defined_symbols(
277278
log.error() << " Could not pointerize '" << sym.get_identifier()
278279
<< "' in function " << gf.first << ". Pretty:\n"
279280
<< sym.pretty() << "\n";
280-
log.error().source_location = iit->source_location;
281+
log.error().source_location = instruction.source_location;
281282
}
282283
log.error() << messaget::eom;
283284
}

src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,11 @@ void disjunctive_polynomial_accelerationt::build_fixed()
858858

859859
fixed.copy_from(goto_program);
860860

861-
Forall_goto_program_instructions(it, fixed)
861+
for(auto &instruction : fixed.instructions)
862862
{
863-
if(it->is_assert())
863+
if(instruction.is_assert())
864864
{
865-
it->type=ASSUME;
865+
instruction.type = ASSUME;
866866
}
867867
}
868868

src/goto-instrument/accelerate/sat_path_enumerator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ void sat_path_enumeratort::build_fixed()
216216

217217
fixed.copy_from(goto_program);
218218

219-
Forall_goto_program_instructions(it, fixed)
219+
for(auto &instruction : fixed.instructions)
220220
{
221-
if(it->is_assert())
222-
it->type=ASSUME;
221+
if(instruction.is_assert())
222+
instruction.type = ASSUME;
223223
}
224224

225225
// We're only interested in paths that loop back to the loop header.

src/goto-instrument/call_sequences.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ static void list_calls_and_arguments(
272272
const namespacet &ns,
273273
const goto_programt &goto_program)
274274
{
275-
forall_goto_program_instructions(i_it, goto_program)
275+
for(const auto &instruction : goto_program.instructions)
276276
{
277-
if(!i_it->is_function_call())
277+
if(!instruction.is_function_call())
278278
continue;
279279

280-
const code_function_callt &call = to_code_function_call(i_it->code);
280+
const code_function_callt &call = to_code_function_call(instruction.code);
281281

282282
const exprt &f=call.function();
283283

0 commit comments

Comments
 (0)