Skip to content

Commit 8a49a13

Browse files
authored
Merge pull request diffblue#4263 from diffblue/use_transform
use instructiont::transform
2 parents 744c6f3 + da678b1 commit 8a49a13

File tree

3 files changed

+30
-33
lines changed

3 files changed

+30
-33
lines changed

src/goto-programs/adjust_float_expressions.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,16 @@ void adjust_float_expressions(
197197
goto_functionst::goto_functiont &goto_function,
198198
const namespacet &ns)
199199
{
200-
Forall_goto_program_instructions(it, goto_function.body)
201-
{
202-
adjust_float_expressions(it->code, ns);
203-
204-
if(it->has_condition())
205-
{
206-
exprt c = it->get_condition();
207-
adjust_float_expressions(c, ns);
208-
it->set_condition(c);
209-
}
210-
}
200+
for(auto &i : goto_function.body.instructions)
201+
i.transform([&ns](exprt expr) -> optionalt<exprt> {
202+
if(have_to_adjust_float_expressions(expr))
203+
{
204+
adjust_float_expressions(expr, ns);
205+
return expr;
206+
}
207+
else
208+
return {};
209+
});
211210
}
212211

213212
void adjust_float_expressions(

src/goto-programs/remove_complex.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,16 @@ static void remove_complex(
285285
{
286286
remove_complex(goto_function.type);
287287

288-
Forall_goto_program_instructions(it, goto_function.body)
289-
{
290-
remove_complex(it->code);
291-
292-
if(it->has_condition())
293-
{
294-
exprt c = it->get_condition();
295-
remove_complex(c);
296-
it->set_condition(c);
297-
}
298-
}
288+
for(auto &i : goto_function.body.instructions)
289+
i.transform([](exprt e) -> optionalt<exprt> {
290+
if(have_to_remove_complex(e))
291+
{
292+
remove_complex(e);
293+
return e;
294+
}
295+
else
296+
return {};
297+
});
299298
}
300299

301300
/// removes complex data type

src/goto-programs/remove_vector.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,16 @@ void remove_vector(goto_functionst::goto_functiont &goto_function)
219219
{
220220
remove_vector(goto_function.type);
221221

222-
Forall_goto_program_instructions(it, goto_function.body)
223-
{
224-
remove_vector(it->code);
225-
226-
if(it->has_condition())
227-
{
228-
exprt c = it->get_condition();
229-
remove_vector(c);
230-
it->set_condition(c);
231-
}
232-
}
222+
for(auto &i : goto_function.body.instructions)
223+
i.transform([](exprt e) -> optionalt<exprt> {
224+
if(have_to_remove_vector(e))
225+
{
226+
remove_vector(e);
227+
return e;
228+
}
229+
else
230+
return {};
231+
});
233232
}
234233

235234
/// removes vector data type

0 commit comments

Comments
 (0)