Skip to content

Commit f778fda

Browse files
committed
Merge 'if new_guard == true' blocks
This means that the symex_transition call is duplicated, but better that one call than multiple if statements.
1 parent 7068354 commit f778fda

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/goto-symex/symex_goto.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,26 +211,25 @@ void goto_symext::symex_goto(statet &state)
211211
framet::goto_state_listt &goto_state_list =
212212
state.call_stack().top().goto_state_map[new_state_pc];
213213

214-
// If the guard is true (and the alternative branch unreachable) we can move
215-
// the state in this case as it'll never be accessed on the alternate branch.
214+
// On an unconditional GOTO we don't need our state, as it will be overwritten
215+
// by merge_goto. Therefore we move it onto goto_state_list instead of copying
216+
// as usual.
216217
if(new_guard.is_true())
217218
{
219+
// The move here only moves goto_statet, the base class of goto_symex_statet
220+
// and not the entire thing.
218221
goto_state_list.emplace_back(state.source, std::move(state));
219-
}
220-
else
221-
{
222-
goto_state_list.emplace_back(state.source, state);
223-
}
224222

225-
symex_transition(state, state_pc, backward);
223+
symex_transition(state, state_pc, backward);
226224

227-
// adjust guards
228-
if(new_guard.is_true())
229-
{
230225
state.guard = guardt(false_exprt(), guard_manager);
231226
}
232227
else
233228
{
229+
goto_state_list.emplace_back(state.source, state);
230+
231+
symex_transition(state, state_pc, backward);
232+
234233
// produce new guard symbol
235234
exprt guard_expr;
236235

0 commit comments

Comments
 (0)