mirror of
git://sourceware.org/git/libabigail.git
synced 2025-01-20 08:20:46 +00:00
A type/decl shouldn't hold a reference on its scope
* src/abg-ir.h (decl_base::m_context): Make this a naked pointer. (decl_base::set_scope, add_decl_to_scope): Pass the scope as a naked pointer. * src/abg-ir.cc (decl_base::decl_base): Initialize the context to 0. (decl_base::set_scope, add_decl_to_scope): Pass the scope as a naked pointer. * src/abg-reader.cc (read_context::get_cur_scope): Return a naked pointer. (handle_namespace_decl): Adjust accordingly.
This commit is contained in:
parent
a5a6fd8fce
commit
dedb3c0d78
@ -142,7 +142,8 @@ decl_base::decl_base()
|
||||
decl_base::decl_base(const std::string& name,
|
||||
location locus)
|
||||
: m_location(locus),
|
||||
m_name(name)
|
||||
m_name(name),
|
||||
m_context(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -176,8 +177,12 @@ decl_base::~decl_base()
|
||||
{
|
||||
}
|
||||
|
||||
/// Setter of the scope of the current decl.
|
||||
///
|
||||
/// Note that the decl won't hold a reference on the scope. It's
|
||||
/// rather the scope that holds a reference on its members.
|
||||
void
|
||||
decl_base::set_scope(shared_ptr<scope_decl> scope)
|
||||
decl_base::set_scope(scope_decl* scope)
|
||||
{
|
||||
m_context = scope;
|
||||
}
|
||||
@ -249,10 +254,10 @@ scope_decl::~scope_decl()
|
||||
///
|
||||
/// \param the decl to add append to the scope
|
||||
///
|
||||
/// \paramt the scope to append the decl to
|
||||
/// \param the scope to append the decl to
|
||||
void
|
||||
add_decl_to_scope(shared_ptr<decl_base> decl,
|
||||
shared_ptr<scope_decl> scope)
|
||||
scope_decl* scope)
|
||||
{
|
||||
if (scope && decl)
|
||||
{
|
||||
|
13
src/abg-ir.h
13
src/abg-ir.h
@ -97,7 +97,7 @@ class decl_base;
|
||||
class scope_decl;
|
||||
|
||||
void add_decl_to_scope(shared_ptr<decl_base>,
|
||||
shared_ptr<scope_decl>);
|
||||
scope_decl*);
|
||||
|
||||
/// \brief The base type of all declarations.
|
||||
class decl_base
|
||||
@ -105,7 +105,7 @@ class decl_base
|
||||
decl_base();
|
||||
|
||||
void
|
||||
set_scope(shared_ptr<scope_decl>);
|
||||
set_scope(scope_decl*);
|
||||
|
||||
public:
|
||||
|
||||
@ -145,7 +145,7 @@ public:
|
||||
m_name = n;
|
||||
}
|
||||
|
||||
shared_ptr<scope_decl>
|
||||
scope_decl*
|
||||
get_scope() const
|
||||
{
|
||||
return m_context;
|
||||
@ -153,11 +153,12 @@ public:
|
||||
|
||||
friend void
|
||||
add_decl_to_scope(shared_ptr<decl_base>,
|
||||
shared_ptr<scope_decl>);
|
||||
scope_decl*);
|
||||
|
||||
private:
|
||||
location m_location;
|
||||
std::string m_name;
|
||||
shared_ptr<scope_decl> m_context;
|
||||
scope_decl* m_context;
|
||||
};
|
||||
|
||||
/// \brief A declaration that introduces a scope.
|
||||
@ -184,7 +185,7 @@ public:
|
||||
|
||||
friend void
|
||||
add_decl_to_scope(shared_ptr<decl_base>,
|
||||
shared_ptr<scope_decl>);
|
||||
scope_decl*);
|
||||
|
||||
private:
|
||||
std::list<shared_ptr<decl_base> > m_members;
|
||||
|
@ -75,21 +75,21 @@ public:
|
||||
/// sane result, the path to the current decl element (starting from the
|
||||
/// root element) must be up to date. It is updated by a call to
|
||||
/// #update_read_context.
|
||||
shared_ptr<scope_decl>
|
||||
scope_decl*
|
||||
get_cur_scope()
|
||||
{
|
||||
shared_ptr<decl_base> cur_decl = get_cur_decl();
|
||||
|
||||
if (dynamic_cast<scope_decl*>(cur_decl.get()))
|
||||
// The current decl is a scope_decl, so it's our lexical scope.
|
||||
return dynamic_pointer_cast<scope_decl>(cur_decl);
|
||||
return dynamic_pointer_cast<scope_decl>(cur_decl).get();
|
||||
else if (cur_decl)
|
||||
// The current decl is not a scope_decl, so our lexical scope is
|
||||
// the scope of this decl.
|
||||
return cur_decl->get_scope();
|
||||
else
|
||||
// We are at global scope.
|
||||
return shared_ptr<scope_decl>(static_cast<scope_decl*>(0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
shared_ptr<decl_base>
|
||||
@ -429,7 +429,7 @@ handle_namespace_decl(read_context& ctxt, abi_corpus& corpus)
|
||||
/// If we are not at global scope, then the current scope must
|
||||
/// itself be a namespace.
|
||||
if (ctxt.get_cur_scope()
|
||||
&& !dynamic_cast<namespace_decl*>(ctxt.get_cur_scope().get()))
|
||||
&& !dynamic_cast<namespace_decl*>(ctxt.get_cur_scope()))
|
||||
return false;
|
||||
|
||||
string name;
|
||||
@ -439,8 +439,6 @@ handle_namespace_decl(read_context& ctxt, abi_corpus& corpus)
|
||||
location loc;
|
||||
read_location(ctxt, corpus, loc);
|
||||
|
||||
shared_ptr<namespace_decl> scope(dynamic_pointer_cast<namespace_decl>
|
||||
(ctxt.get_cur_scope()));
|
||||
shared_ptr<decl_base> decl(new namespace_decl(name, loc));
|
||||
ctxt.finish_decl_creation(decl, corpus);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user