Skip to content

Commit a21d400

Browse files
author
Daniel Kroening
committed
use instructiont::apply
1 parent 92721db commit a21d400

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/goto-programs/compute_called_functions.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,8 @@ void compute_address_taken_functions(
5454
const goto_programt &goto_program,
5555
std::unordered_set<irep_idt> &address_taken)
5656
{
57-
forall_goto_program_instructions(it, goto_program)
58-
{
59-
if(it->has_condition())
60-
compute_address_taken_functions(it->get_condition(), address_taken);
61-
62-
compute_address_taken_functions(it->code, address_taken);
63-
}
57+
for(const auto &i : goto_program.instructions)
58+
i.apply([&address_taken](const exprt &expr) { compute_address_taken_functions(expr, address_taken); });
6459
}
6560

6661
/// get all functions whose address is taken

src/goto-programs/slice_global_inits.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,15 @@ void slice_global_inits(goto_modelt &goto_model)
6161
if(it == goto_functions.function_map.end())
6262
continue;
6363

64-
const goto_programt &goto_program = it->second.body;
65-
66-
forall_goto_program_instructions(i_it, goto_program)
67-
{
68-
const codet &code = i_it->code;
69-
find_symbols(code, symbols, true, false);
70-
71-
if(i_it->has_condition())
72-
find_symbols(i_it->get_condition(), symbols, true, false);
73-
}
64+
for(const auto &i : it->second.body.instructions)
65+
i.apply([&symbols](const exprt &expr) { find_symbols(expr, symbols, true, false); });
7466
}
7567

7668
// now remove unnecessary initializations
7769

7870
goto_functionst::function_mapt::iterator f_it;
7971
f_it=goto_functions.function_map.find(INITIALIZE_FUNCTION);
72+
8073
if(f_it == goto_functions.function_map.end())
8174
throw incorrect_goto_program_exceptiont("initialize function not found");
8275

0 commit comments

Comments
 (0)