mirror of
git://sourceware.org/git/libabigail.git
synced 2025-03-05 22:27:34 +00:00
Avoid having multiple sub-objects of base classes
* src/abg-ir.cc (decl_base::decl_base): Remove useless definition. (type_base::type_base): Remove default arguments from parameters. (scope_type_decl::scope_type_decl) (namespace_decl::namespace_decl): Call the constructors for the virtual bases explicitly. * src/abg-ir.h (class scope_decl): Perform virtual inheritance of decl_base. (global_scope::global_scope): Call virtual base decl_base's constructor directly. (class type_decl): Inherit from decl_base and type_base virtually. (class scope_type_decl): Inherit from type_base virtually. (class qualified_type_def, pointer_type_def, reference_type_def) (class enum_type_decl, typedef_decl): Inherit from type_base and decl_base virtually. (class var_decl, function_decl): Inherit from decl_base virtually. (class class_decl::member): Don't inherit from anything and adjust constructor's mem-initializer accordingly. (class class_decl::member_type): Inherit from decl_base virtually and adjust constructor's mem-initializer accordingly. (class_decl::{data_member::data_member,member_function::member_function) (class_decl::class_decl): Call virtual base's constructor explicitly.
This commit is contained in:
parent
04ad3184ba
commit
80d0e29f69
@ -214,9 +214,6 @@ translation_unit::is_empty() const
|
||||
}
|
||||
|
||||
// <Decl definition>
|
||||
decl_base::decl_base()
|
||||
{
|
||||
}
|
||||
|
||||
decl_base::decl_base(const std::string& name,
|
||||
location locus,
|
||||
@ -417,7 +414,7 @@ global_scope::~global_scope()
|
||||
}
|
||||
|
||||
// <type_base definitions>
|
||||
type_base::type_base(size_t s = 8, size_t a = 8)
|
||||
type_base::type_base(size_t s, size_t a)
|
||||
: m_size_in_bits(s),
|
||||
m_alignment_in_bits(a)
|
||||
{
|
||||
@ -533,8 +530,9 @@ scope_type_decl::scope_type_decl(const std::string& name,
|
||||
size_t alignment_in_bits,
|
||||
location locus,
|
||||
visibility vis)
|
||||
:scope_decl(name, locus, vis),
|
||||
type_base(size_in_bits, alignment_in_bits)
|
||||
: decl_base(name, locus, "", vis),
|
||||
type_base(size_in_bits, alignment_in_bits),
|
||||
scope_decl(name, locus)
|
||||
{
|
||||
}
|
||||
|
||||
@ -577,7 +575,14 @@ scope_type_decl_hash::operator()(const scope_type_decl& t) const
|
||||
namespace_decl::namespace_decl(const std::string& name,
|
||||
location locus,
|
||||
visibility vis)
|
||||
: scope_decl(name, locus, vis)
|
||||
: // We need to call the constructor of decl_base directly here
|
||||
// because it is virtually inherited by scope_decl. Note that we
|
||||
// just implicitely call the default constructor for scope_decl
|
||||
// here, as what we really want is to initialize the decl_base
|
||||
// subobject. Wow, virtual inheritance is useful, but setting it
|
||||
// up is ugly.
|
||||
decl_base(name, locus, "", vis),
|
||||
scope_decl(name, locus)
|
||||
{
|
||||
}
|
||||
|
||||
|
58
src/abg-ir.h
58
src/abg-ir.h
@ -260,7 +260,7 @@ private:
|
||||
|
||||
|
||||
/// \brief A declaration that introduces a scope.
|
||||
class scope_decl : public decl_base
|
||||
class scope_decl : public virtual decl_base
|
||||
{
|
||||
scope_decl();
|
||||
|
||||
@ -320,7 +320,8 @@ struct decl_base_hash
|
||||
class global_scope : public scope_decl
|
||||
{
|
||||
global_scope()
|
||||
: scope_decl("", location()),
|
||||
: decl_base("", location()),
|
||||
scope_decl("", location()),
|
||||
m_translation_unit(0)
|
||||
{
|
||||
}
|
||||
@ -419,7 +420,7 @@ struct type_shared_ptr_equal
|
||||
};//end struct type_shared_ptr_equal
|
||||
|
||||
/// A basic type declaration that introduces no scope.
|
||||
class type_decl : public decl_base, public type_base
|
||||
class type_decl : public virtual decl_base, public virtual type_base
|
||||
{
|
||||
// Forbidden.
|
||||
type_decl();
|
||||
@ -447,7 +448,7 @@ struct type_decl_hash
|
||||
};//end struct type_decl_hash
|
||||
|
||||
/// A type that introduces a scope.
|
||||
class scope_type_decl : public scope_decl, public type_base
|
||||
class scope_type_decl : public scope_decl, public virtual type_base
|
||||
{
|
||||
scope_type_decl();
|
||||
|
||||
@ -489,7 +490,7 @@ public:
|
||||
};//end class namespace_decl
|
||||
|
||||
/// The abstraction of a qualified type.
|
||||
class qualified_type_def : public type_base, public decl_base
|
||||
class qualified_type_def : public virtual type_base, public virtual decl_base
|
||||
{
|
||||
|
||||
// Forbidden.
|
||||
@ -535,7 +536,8 @@ struct qualified_type_def_hash
|
||||
};//end struct qualified_type_def_hash
|
||||
|
||||
/// The abstraction of a pointer type.
|
||||
class pointer_type_def : public type_base, public decl_base
|
||||
class pointer_type_def : public virtual type_base,
|
||||
public virtual decl_base
|
||||
{
|
||||
// Forbidden.
|
||||
pointer_type_def();
|
||||
@ -567,7 +569,8 @@ struct pointer_type_def_hash
|
||||
};// end struct pointer_type_def_hash
|
||||
|
||||
/// Abstracts a reference type.
|
||||
class reference_type_def : public type_base, public decl_base
|
||||
class reference_type_def : public virtual type_base,
|
||||
public virtual decl_base
|
||||
{
|
||||
// Forbidden.
|
||||
reference_type_def();
|
||||
@ -603,7 +606,8 @@ struct reference_type_def_hash
|
||||
};//end struct reference_type_def_hash
|
||||
|
||||
/// Abstracts a declaration for an enum type.
|
||||
class enum_type_decl: public type_base, public decl_base
|
||||
class enum_type_decl: public virtual type_base,
|
||||
public virtual decl_base
|
||||
{
|
||||
// Forbidden
|
||||
enum_type_decl();
|
||||
@ -683,7 +687,8 @@ struct enum_type_decl_hash
|
||||
};//end struct enum_type_decl_hash
|
||||
|
||||
/// The abstraction of a typedef declaration.
|
||||
class typedef_decl: public type_base, public decl_base
|
||||
class typedef_decl: public virtual type_base,
|
||||
public virtual decl_base
|
||||
{
|
||||
// Forbidden
|
||||
typedef_decl();
|
||||
@ -717,7 +722,7 @@ struct typedef_decl_hash
|
||||
};// end struct typedef_decl_hash
|
||||
|
||||
/// Abstracts a variable declaration.
|
||||
class var_decl : public decl_base
|
||||
class var_decl : public virtual decl_base
|
||||
{
|
||||
// Forbidden
|
||||
var_decl();
|
||||
@ -762,7 +767,7 @@ struct var_decl_hash
|
||||
};// end struct var_decl_hash
|
||||
|
||||
/// Abstraction for a function declaration.
|
||||
class function_decl: public decl_base
|
||||
class function_decl: public virtual decl_base
|
||||
{
|
||||
public:
|
||||
|
||||
@ -896,15 +901,14 @@ public:
|
||||
/// functions. Its purpose is to mainly to carry the access
|
||||
/// specifier (and possibly other properties that might be shared by
|
||||
/// all class members) for the member.
|
||||
class member : scope_decl
|
||||
class member
|
||||
{
|
||||
// Forbidden
|
||||
member();
|
||||
public:
|
||||
|
||||
member(access_specifier a)
|
||||
: scope_decl("", location(), VISIBILITY_NONE),
|
||||
m_access(a)
|
||||
: m_access(a)
|
||||
{}
|
||||
|
||||
access_specifier
|
||||
@ -931,7 +935,7 @@ public:
|
||||
};// struct member_hash
|
||||
|
||||
/// Abstracts a member type declaration.
|
||||
class member_type : public member
|
||||
class member_type : public member, public virtual decl_base
|
||||
{
|
||||
//Forbidden
|
||||
member_type();
|
||||
@ -940,7 +944,8 @@ public:
|
||||
|
||||
member_type(shared_ptr<type_base> t,
|
||||
access_specifier access)
|
||||
: member(access),
|
||||
: decl_base("", location()),
|
||||
member(access),
|
||||
m_type(t)
|
||||
{
|
||||
}
|
||||
@ -1020,7 +1025,11 @@ public:
|
||||
bool is_laid_out,
|
||||
bool is_static,
|
||||
size_t offset_in_bits)
|
||||
: var_decl(data_member->get_name(),
|
||||
: decl_base(data_member->get_name(),
|
||||
data_member->get_location(),
|
||||
data_member->get_mangled_name(),
|
||||
data_member->get_visibility()),
|
||||
var_decl(data_member->get_name(),
|
||||
data_member->get_type(),
|
||||
data_member->get_location(),
|
||||
data_member->get_mangled_name(),
|
||||
@ -1042,7 +1051,8 @@ public:
|
||||
bool is_laid_out,
|
||||
bool is_static,
|
||||
size_t offset_in_bits)
|
||||
: var_decl(name, type, locus, mangled_name, vis, bind),
|
||||
: decl_base(name, locus, name, vis),
|
||||
var_decl(name, type, locus, mangled_name, vis, bind),
|
||||
member(access),
|
||||
m_is_laid_out(is_laid_out),
|
||||
m_is_static(is_static),
|
||||
@ -1107,7 +1117,8 @@ public:
|
||||
bool is_constructor,
|
||||
bool is_destructor,
|
||||
bool is_const)
|
||||
: function_decl(name, parms, return_type, declared_inline,
|
||||
: decl_base(name, locus, name, vis),
|
||||
function_decl(name, parms, return_type, declared_inline,
|
||||
locus, mangled_name, vis, bind),
|
||||
member(access),
|
||||
m_vtable_offset_in_bits(vtable_offset_in_bits),
|
||||
@ -1124,7 +1135,9 @@ public:
|
||||
bool is_constructor,
|
||||
bool is_destructor,
|
||||
bool is_const)
|
||||
: function_decl(fn->get_name(),
|
||||
: decl_base(fn->get_name(), fn->get_location(),
|
||||
fn->get_mangled_name(), fn->get_visibility()),
|
||||
function_decl(fn->get_name(),
|
||||
fn->get_parameters(),
|
||||
fn->get_return_type(),
|
||||
fn->is_declared_inline(),
|
||||
@ -1196,8 +1209,9 @@ public:
|
||||
const std::list<shared_ptr<member_type> >& member_types,
|
||||
const std::list<shared_ptr<data_member> >& data_members,
|
||||
const std::list<shared_ptr<member_function> >& member_fns)
|
||||
: scope_type_decl(name, size_in_bits, align_in_bits,
|
||||
locus, vis),
|
||||
: decl_base(name, locus, name, vis),
|
||||
type_base(size_in_bits, align_in_bits),
|
||||
scope_type_decl(name, size_in_bits, align_in_bits, locus, vis),
|
||||
m_bases(bases),
|
||||
m_member_types(member_types),
|
||||
m_data_members(data_members),
|
||||
|
Loading…
Reference in New Issue
Block a user