diff --git a/src/goto-programs/adjust_float_expressions.cpp b/src/goto-programs/adjust_float_expressions.cpp index b66c12b32e4..25194e1ce3b 100644 --- a/src/goto-programs/adjust_float_expressions.cpp +++ b/src/goto-programs/adjust_float_expressions.cpp @@ -197,17 +197,16 @@ void adjust_float_expressions( goto_functionst::goto_functiont &goto_function, const namespacet &ns) { - Forall_goto_program_instructions(it, goto_function.body) - { - adjust_float_expressions(it->code, ns); - - if(it->has_condition()) - { - exprt c = it->get_condition(); - adjust_float_expressions(c, ns); - it->set_condition(c); - } - } + for(auto &i : goto_function.body.instructions) + i.transform([&ns](exprt expr) -> optionalt { + if(have_to_adjust_float_expressions(expr)) + { + adjust_float_expressions(expr, ns); + return expr; + } + else + return {}; + }); } void adjust_float_expressions( diff --git a/src/goto-programs/remove_complex.cpp b/src/goto-programs/remove_complex.cpp index 9cf7a010b2e..e0a95651877 100644 --- a/src/goto-programs/remove_complex.cpp +++ b/src/goto-programs/remove_complex.cpp @@ -285,17 +285,16 @@ static void remove_complex( { remove_complex(goto_function.type); - Forall_goto_program_instructions(it, goto_function.body) - { - remove_complex(it->code); - - if(it->has_condition()) - { - exprt c = it->get_condition(); - remove_complex(c); - it->set_condition(c); - } - } + for(auto &i : goto_function.body.instructions) + i.transform([](exprt e) -> optionalt { + if(have_to_remove_complex(e)) + { + remove_complex(e); + return e; + } + else + return {}; + }); } /// removes complex data type diff --git a/src/goto-programs/remove_vector.cpp b/src/goto-programs/remove_vector.cpp index 42b1601de06..7b4ff901909 100644 --- a/src/goto-programs/remove_vector.cpp +++ b/src/goto-programs/remove_vector.cpp @@ -219,17 +219,16 @@ void remove_vector(goto_functionst::goto_functiont &goto_function) { remove_vector(goto_function.type); - Forall_goto_program_instructions(it, goto_function.body) - { - remove_vector(it->code); - - if(it->has_condition()) - { - exprt c = it->get_condition(); - remove_vector(c); - it->set_condition(c); - } - } + for(auto &i : goto_function.body.instructions) + i.transform([](exprt e) -> optionalt { + if(have_to_remove_vector(e)) + { + remove_vector(e); + return e; + } + else + return {}; + }); } /// removes vector data type