Skip to content

Make renamedt inherit from underlyingt #4454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/goto-symex/goto_symex_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ goto_symex_statet::rename(exprt expr, const namespacet &ns)
if(level == L0)
{
return renamedt<exprt, level>{
std::move(rename_ssa<L0>(std::move(ssa), ns).value)};
std::move(rename_ssa<L0>(std::move(ssa), ns).value())};
}
else if(level == L1)
{
return renamedt<exprt, level>{
std::move(rename_ssa<L1>(std::move(ssa), ns).value)};
std::move(rename_ssa<L1>(std::move(ssa), ns).value())};
}
else if(level==L2)
{
Expand Down
14 changes: 7 additions & 7 deletions src/goto-symex/renaming_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,27 @@ operator()(renamedt<ssa_exprt, L0> l0_expr) const
!l0_expr.get().get_level_1().empty() ||
!l0_expr.get().get_level_2().empty())
{
return renamedt<ssa_exprt, L1>{std::move(l0_expr.value)};
return renamedt<ssa_exprt, L1>{std::move(l0_expr.value())};
}

const irep_idt l0_name = l0_expr.get().get_l1_object_identifier();

const auto it = current_names.find(l0_name);
if(it == current_names.end())
return renamedt<ssa_exprt, L1>{std::move(l0_expr.value)};
return renamedt<ssa_exprt, L1>{std::move(l0_expr.value())};

// rename!
l0_expr.value.set_level_1(it->second.second);
return renamedt<ssa_exprt, L1>{std::move(l0_expr.value)};
l0_expr.value().set_level_1(it->second.second);
return renamedt<ssa_exprt, L1>{std::move(l0_expr.value())};
}

renamedt<ssa_exprt, L2> symex_level2t::
operator()(renamedt<ssa_exprt, L1> l1_expr) const
{
if(!l1_expr.get().get_level_2().empty())
return renamedt<ssa_exprt, L2>{std::move(l1_expr.value)};
l1_expr.value.set_level_2(current_count(l1_expr.get().get_identifier()));
return renamedt<ssa_exprt, L2>{std::move(l1_expr.value)};
return renamedt<ssa_exprt, L2>{std::move(l1_expr.value())};
l1_expr.value().set_level_2(current_count(l1_expr.get().get_identifier()));
return renamedt<ssa_exprt, L2>{std::move(l1_expr.value())};
}

void symex_level1t::restore_from(const current_namest &other)
Expand Down
13 changes: 8 additions & 5 deletions src/goto-symex/renaming_level.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct symex_renaming_levelt
/// Wrapper for expressions or types which have been renamed up to a given
/// \p level
template <typename underlyingt, levelt level>
class renamedt
class renamedt : private underlyingt
{
public:
static_assert(
Expand All @@ -79,24 +79,27 @@ class renamedt

const underlyingt &get() const
{
return value;
return static_cast<const underlyingt &>(*this);
}

void simplify(const namespacet &ns)
{
(void)::simplify(value, ns);
(void)::simplify(value(), ns);
}

private:
underlyingt value;
underlyingt &value()
{
return static_cast<underlyingt &>(*this);
};

friend struct symex_level0t;
friend struct symex_level1t;
friend struct symex_level2t;
friend class goto_symex_statet;

/// Only the friend classes can create renamedt objects
explicit renamedt(underlyingt value) : value(std::move(value))
explicit renamedt(underlyingt value) : underlyingt(std::move(value))
{
}
};
Expand Down