Skip to content

Commit 15610d6

Browse files
author
Daniel Kroening
committed
use transform() in rewrite_union
1 parent 6879ae4 commit 15610d6

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/goto-programs/rewrite_union.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,16 @@ void rewrite_union(exprt &expr)
101101

102102
void rewrite_union(goto_functionst::goto_functiont &goto_function)
103103
{
104-
Forall_goto_program_instructions(it, goto_function.body)
105-
{
106-
rewrite_union(it->code);
107-
108-
if(it->has_condition())
109-
{
110-
exprt c = it->get_condition();
111-
rewrite_union(c);
112-
it->set_condition(c);
113-
}
114-
}
104+
for(auto &instruction : goto_function.body.instructions)
105+
instruction.transform([](exprt src) -> optionalt<exprt> {
106+
if(!have_to_rewrite_union(src))
107+
return {};
108+
else
109+
{
110+
rewrite_union(src);
111+
return src;
112+
}
113+
});
115114
}
116115

117116
void rewrite_union(goto_functionst &goto_functions)

0 commit comments

Comments
 (0)