Skip to content

Commit 6441467

Browse files
committed
Move increase_generation onto goto_statet
This enables us to more conveniently allocate a new generation on a non-current state, such as a state copy that will be used on a pending branch. No behavioural change.
1 parent 929c21d commit 6441467

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/goto-symex/goto_state.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,17 @@ void goto_statet::output_propagation_map(std::ostream &out)
2020
out << name_value.first << " <- " << format(name_value.second) << "\n";
2121
}
2222
}
23+
24+
std::size_t goto_statet::increase_generation(
25+
const irep_idt l1_identifier,
26+
const ssa_exprt &lhs,
27+
std::function<std::size_t(const irep_idt &)> fresh_l2_name_provider)
28+
{
29+
auto current_emplace_res =
30+
level2.current_names.emplace(l1_identifier, std::make_pair(lhs, 0));
31+
32+
current_emplace_res.first->second.second =
33+
fresh_l2_name_provider(l1_identifier);
34+
35+
return current_emplace_res.first->second.second;
36+
}

src/goto-symex/goto_state.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ class goto_statet
7474
: guard(true_exprt(), guard_manager)
7575
{
7676
}
77+
78+
std::size_t increase_generation(
79+
const irep_idt l1_identifier,
80+
const ssa_exprt &lhs,
81+
std::function<std::size_t(const irep_idt &)> fresh_l2_name_provider);
7782
};
7883

7984
#endif // CPROVER_GOTO_SYMEX_GOTO_STATE_H

src/goto-symex/goto_symex_state.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -459,22 +459,6 @@ bool goto_symex_statet::l2_thread_read_encoding(
459459
return true;
460460
}
461461

462-
/// Allocates a fresh L2 name for the given L1 identifier, and makes it the
463-
/// latest generation on this path.
464-
/// \return the newly allocated generation number
465-
std::size_t goto_symex_statet::increase_generation(
466-
const irep_idt l1_identifier,
467-
const ssa_exprt &lhs)
468-
{
469-
auto current_emplace_res =
470-
level2.current_names.emplace(l1_identifier, std::make_pair(lhs, 0));
471-
472-
current_emplace_res.first->second.second =
473-
fresh_l2_name_provider(l1_identifier);
474-
475-
return current_emplace_res.first->second.second;
476-
}
477-
478462
/// Allocates a fresh L2 name for the given L1 identifier, and makes it the
479463
/// latest generation on this path. Does nothing if there isn't an expression
480464
/// keyed by the l1 identifier.

src/goto-symex/goto_symex_state.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ class goto_symex_statet final : public goto_statet
208208
/// Allocates a fresh L2 name for the given L1 identifier, and makes it the
209209
// latest generation on this path.
210210
std::size_t
211-
increase_generation(const irep_idt l1_identifier, const ssa_exprt &lhs);
211+
increase_generation(const irep_idt l1_identifier, const ssa_exprt &lhs)
212+
{
213+
return goto_statet::increase_generation(
214+
l1_identifier, lhs, fresh_l2_name_provider);
215+
}
212216

213217
/// Increases the generation of the L1 identifier. Does nothing if there
214218
/// isn't an expression keyed by it.

0 commit comments

Comments
 (0)