mirror of
git://sourceware.org/git/libabigail.git
synced 2025-01-18 15:20:45 +00:00
Do not declare classes before defining them anymore
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Do not declare classes before defining them because both the declaration and the definition now compare equal. * tests/data/test-read-dwarf/test1.abi: Update test. * tests/data/test-read-write/test20.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
b78e3371e5
commit
42aaa3124e
@ -2228,46 +2228,32 @@ build_class_type_and_add_to_ir(read_context& ctxt,
|
||||
size_t size = 0;
|
||||
die_size_in_bits(die, size);
|
||||
|
||||
class_decl_sptr cur_class_decl;
|
||||
decl_base_sptr cur_class, res;
|
||||
|
||||
if (klass)
|
||||
{
|
||||
cur_class_decl = klass;
|
||||
cur_class = klass;
|
||||
result = klass;
|
||||
}
|
||||
else
|
||||
{
|
||||
cur_class_decl.reset(new class_decl(name, is_struct));
|
||||
cur_class = add_decl_to_scope(cur_class_decl, scope);
|
||||
}
|
||||
|
||||
Dwarf_Die child;
|
||||
bool has_child = (dwarf_child(die, &child) == 0);
|
||||
bool is_declaration_only = die_is_declaration_only(die);
|
||||
|
||||
if (!has_child && is_declaration_only)
|
||||
// TODO: set the access specifier for the declaration-only class
|
||||
// here.
|
||||
return cur_class;
|
||||
|
||||
if (!klass)
|
||||
decl_base_sptr res;
|
||||
if (klass)
|
||||
result = klass;
|
||||
else
|
||||
{
|
||||
ctxt.die_wip_classes_map()[dwarf_dieoffset(die)] = cur_class;
|
||||
|
||||
if (is_declaration_only)
|
||||
result.reset(new class_decl(name, is_struct));
|
||||
else
|
||||
result.reset(new class_decl(name, size, 0, is_struct, loc,
|
||||
decl_base::VISIBILITY_DEFAULT));
|
||||
res = add_decl_to_scope(result, scope);
|
||||
assert(cur_class_decl->is_declaration_only());
|
||||
cur_class_decl->set_definition_of_declaration(result);
|
||||
result = dynamic_pointer_cast<class_decl>(as_non_member_type(res));
|
||||
assert(result);
|
||||
}
|
||||
|
||||
if (!has_child)
|
||||
// TODO: set the access specifier for the declaration-only class
|
||||
// here.
|
||||
return res;
|
||||
|
||||
ctxt.die_wip_classes_map()[dwarf_dieoffset(die)] = res;
|
||||
|
||||
scope_decl_sptr scop =
|
||||
dynamic_pointer_cast<scope_decl>
|
||||
(get_type_declaration(as_non_member_type(res)));
|
||||
@ -2415,7 +2401,7 @@ build_class_type_and_add_to_ir(read_context& ctxt,
|
||||
class_decl_sptr k =
|
||||
dynamic_pointer_cast<class_decl>
|
||||
(this_type->get_pointed_to_type());
|
||||
if (k && *k == *cur_class_decl)
|
||||
if (k && *k == *result)
|
||||
is_static = true;
|
||||
}
|
||||
}
|
||||
@ -2460,7 +2446,6 @@ build_class_type_and_add_to_ir(read_context& ctxt,
|
||||
ctxt.die_wip_classes_map().find(dwarf_dieoffset(die));
|
||||
if (i != ctxt.die_wip_classes_map().end())
|
||||
{
|
||||
result->set_earlier_declaration(i->second);
|
||||
class_decl::member_type_sptr m =
|
||||
dynamic_pointer_cast<class_decl::member_type>(i->second);
|
||||
if (m)
|
||||
|
@ -1,71 +1,68 @@
|
||||
<abi-corpus path='data/test-read-dwarf/test1'>
|
||||
<abi-instr version='1.0' address-size='64' path='test1.cc'>
|
||||
<class-decl name='s0' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-1'/>
|
||||
<class-decl name='s0' size-in-bits='384' is-struct='yes' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='13' column='1' def-of-decl-id='type-id-1' id='type-id-2'>
|
||||
<base-class access='public' layout-offset-in-bits='24' is-virtual='yes' type-id='type-id-3'/>
|
||||
<base-class access='public' layout-offset-in-bits='32' is-virtual='yes' type-id='type-id-4'/>
|
||||
<class-decl name='s0' size-in-bits='384' is-struct='yes' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='13' column='1' id='type-id-1'>
|
||||
<base-class access='public' layout-offset-in-bits='24' is-virtual='yes' type-id='type-id-2'/>
|
||||
<base-class access='public' layout-offset-in-bits='32' is-virtual='yes' type-id='type-id-3'/>
|
||||
<member-type access='public'>
|
||||
<typedef-decl name='integer' type-id='type-id-6' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='15' column='1' id='type-id-5'/>
|
||||
<typedef-decl name='integer' type-id='type-id-5' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='15' column='1' id='type-id-4'/>
|
||||
</member-type>
|
||||
<member-type access='public'>
|
||||
<typedef-decl name='byte' type-id='type-id-8' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='16' column='1' id='type-id-7'/>
|
||||
<typedef-decl name='byte' type-id='type-id-7' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='16' column='1' id='type-id-6'/>
|
||||
</member-type>
|
||||
<data-member access='public' layout-offset-in-bits='64'>
|
||||
<var-decl name='m0' type-id='type-id-5' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='18' column='1'/>
|
||||
<var-decl name='m0' type-id='type-id-4' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='18' column='1'/>
|
||||
</data-member>
|
||||
<data-member access='public' layout-offset-in-bits='96'>
|
||||
<var-decl name='m1' type-id='type-id-7' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='19' column='1'/>
|
||||
<var-decl name='m1' type-id='type-id-6' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='19' column='1'/>
|
||||
</data-member>
|
||||
<member-function access='public' constructor='yes'>
|
||||
<function-decl name='s0' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='21' column='1' visibility='default' binding='global' size-in-bits='64' alignment-in-bits='64'>
|
||||
<parameter type-id='type-id-9' is-artificial='yes'/>
|
||||
<parameter type-id='type-id-6' is-artificial='yes'/>
|
||||
<parameter type-id='type-id-8' is-artificial='yes'/>
|
||||
<parameter type-id='type-id-5' is-artificial='yes'/>
|
||||
</function-decl>
|
||||
</member-function>
|
||||
<member-function access='public' destructor='yes'>
|
||||
<function-decl name='~s0' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='27' column='1' visibility='default' binding='global' size-in-bits='64' alignment-in-bits='64'>
|
||||
<parameter type-id='type-id-9' is-artificial='yes'/>
|
||||
<parameter type-id='type-id-6' is-artificial='yes'/>
|
||||
<parameter type-id='type-id-8' is-artificial='yes'/>
|
||||
<parameter type-id='type-id-5' is-artificial='yes'/>
|
||||
</function-decl>
|
||||
</member-function>
|
||||
<member-function access='public'>
|
||||
<function-decl name='mem_fun' mangled-name='_ZN2s07mem_funEv' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='36' column='1' visibility='default' binding='global' size-in-bits='64' alignment-in-bits='64'>
|
||||
<parameter type-id='type-id-9' is-artificial='yes'/>
|
||||
<return type-id='type-id-5'/>
|
||||
<parameter type-id='type-id-8' is-artificial='yes'/>
|
||||
<return type-id='type-id-4'/>
|
||||
</function-decl>
|
||||
</member-function>
|
||||
</class-decl>
|
||||
<class-decl name='b0' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-10'/>
|
||||
<class-decl name='b0' size-in-bits='128' is-struct='yes' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='1' column='1' def-of-decl-id='type-id-10' id='type-id-3'>
|
||||
<class-decl name='b0' size-in-bits='128' is-struct='yes' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='1' column='1' id='type-id-2'>
|
||||
<data-member access='public' layout-offset-in-bits='0'>
|
||||
<var-decl name='m0' type-id='type-id-11' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='3' column='1'/>
|
||||
<var-decl name='m0' type-id='type-id-9' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='3' column='1'/>
|
||||
</data-member>
|
||||
<data-member access='public' layout-offset-in-bits='64'>
|
||||
<var-decl name='m1' type-id='type-id-12' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='4' column='1'/>
|
||||
<var-decl name='m1' type-id='type-id-10' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='4' column='1'/>
|
||||
</data-member>
|
||||
</class-decl>
|
||||
<type-decl name='long long int' size-in-bits='64' alignment-in-bits='64' id='type-id-11'/>
|
||||
<type-decl name='char' size-in-bits='8' alignment-in-bits='8' id='type-id-12'/>
|
||||
<class-decl name='b1' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-13'/>
|
||||
<class-decl name='b1' size-in-bits='128' is-struct='yes' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='7' column='1' def-of-decl-id='type-id-13' id='type-id-4'>
|
||||
<type-decl name='long long int' size-in-bits='64' alignment-in-bits='64' id='type-id-9'/>
|
||||
<type-decl name='char' size-in-bits='8' alignment-in-bits='8' id='type-id-10'/>
|
||||
<class-decl name='b1' size-in-bits='128' is-struct='yes' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='7' column='1' id='type-id-3'>
|
||||
<data-member access='public' layout-offset-in-bits='0'>
|
||||
<var-decl name='m0' type-id='type-id-14' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='9' column='1'/>
|
||||
<var-decl name='m0' type-id='type-id-11' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='9' column='1'/>
|
||||
</data-member>
|
||||
<data-member access='public' layout-offset-in-bits='64'>
|
||||
<var-decl name='m1' type-id='type-id-12' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='10' column='1'/>
|
||||
<var-decl name='m1' type-id='type-id-10' visibility='default' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='10' column='1'/>
|
||||
</data-member>
|
||||
</class-decl>
|
||||
<type-decl name='double' size-in-bits='64' alignment-in-bits='64' id='type-id-14'/>
|
||||
<type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-6'/>
|
||||
<type-decl name='unsigned char' size-in-bits='8' alignment-in-bits='8' id='type-id-8'/>
|
||||
<pointer-type-def type-id='type-id-1' size-in-bits='64' alignment-in-bits='64' id='type-id-9'/>
|
||||
<reference-type-def kind='lvalue' type-id='type-id-2' size-in-bits='64' alignment-in-bits='64' id='type-id-15'/>
|
||||
<qualified-type-def type-id='type-id-15' const='yes' id='type-id-16'/>
|
||||
<type-decl name='double' size-in-bits='64' alignment-in-bits='64' id='type-id-11'/>
|
||||
<type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-5'/>
|
||||
<type-decl name='unsigned char' size-in-bits='8' alignment-in-bits='8' id='type-id-7'/>
|
||||
<pointer-type-def type-id='type-id-1' size-in-bits='64' alignment-in-bits='64' id='type-id-8'/>
|
||||
<reference-type-def kind='lvalue' type-id='type-id-1' size-in-bits='64' alignment-in-bits='64' id='type-id-12'/>
|
||||
<qualified-type-def type-id='type-id-12' const='yes' id='type-id-13'/>
|
||||
<function-decl name='foo' mangled-name='_Z3fooR2s0' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='42' column='1' visibility='default' binding='global' size-in-bits='64' alignment-in-bits='64'>
|
||||
<parameter type-id='type-id-16' name='s' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='42' column='1'/>
|
||||
<parameter type-id='type-id-13' name='s' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='42' column='1'/>
|
||||
</function-decl>
|
||||
<function-decl name='main' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='48' column='1' visibility='default' binding='global' size-in-bits='64' alignment-in-bits='64'>
|
||||
<return type-id='type-id-6'/>
|
||||
<return type-id='type-id-5'/>
|
||||
</function-decl>
|
||||
</abi-instr>
|
||||
</abi-corpus>
|
||||
|
@ -23,9 +23,7 @@
|
||||
</function-decl>
|
||||
</member-function>
|
||||
</class-decl>
|
||||
<class-decl name='B1' visibility='default' is-declaration-only='yes' id='type-id-6'/>
|
||||
<pointer-type-def type-id='type-id-6' size-in-bits='64' alignment-in-bits='64' id='type-id-7'/>
|
||||
<class-decl name='B1' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='../../prtests/test9.cc' line='20' column='7' def-of-decl-id='type-id-6' id='type-id-8'>
|
||||
<class-decl name='B1' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='../../prtests/test9.cc' line='20' column='7' id='type-id-6'>
|
||||
<data-member access='private' layout-offset-in-bits='0'>
|
||||
<var-decl name='m0' type-id='type-id-2' visibility='default' filepath='../../prtests/test9.cc' line='22' column='7'/>
|
||||
</data-member>
|
||||
@ -42,47 +40,48 @@
|
||||
</function-decl>
|
||||
</member-function>
|
||||
</class-decl>
|
||||
<class-decl name='B2' visibility='default' is-declaration-only='yes' id='type-id-9'/>
|
||||
<pointer-type-def type-id='type-id-9' size-in-bits='64' alignment-in-bits='64' id='type-id-10'/>
|
||||
<class-decl name='B2' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='../../prtests/test9.cc' line='39' column='7' def-of-decl-id='type-id-9' id='type-id-11'>
|
||||
<pointer-type-def type-id='type-id-6' size-in-bits='64' alignment-in-bits='64' id='type-id-7'/>
|
||||
<class-decl name='B2' visibility='default' is-declaration-only='yes' id='type-id-8'/>
|
||||
<pointer-type-def type-id='type-id-8' size-in-bits='64' alignment-in-bits='64' id='type-id-9'/>
|
||||
<class-decl name='B2' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='../../prtests/test9.cc' line='39' column='7' def-of-decl-id='type-id-8' id='type-id-10'>
|
||||
<data-member access='private' layout-offset-in-bits='0'>
|
||||
<var-decl name='m0' type-id='type-id-2' visibility='default' filepath='../../prtests/test9.cc' line='41' column='7'/>
|
||||
</data-member>
|
||||
<member-function access='public'>
|
||||
<function-decl name='__base_ctor ' mangled-name='_ZN2B2C2Ev' filepath='../../prtests/test9.cc' line='45' column='3' declared-inline='yes' visibility='default' binding='weak' size-in-bits='8' alignment-in-bits='8'>
|
||||
<parameter type-id='type-id-10'/>
|
||||
<parameter type-id='type-id-9'/>
|
||||
<return type-id='type-id-1'/>
|
||||
</function-decl>
|
||||
</member-function>
|
||||
<member-function access='public'>
|
||||
<function-decl name='__comp_ctor ' mangled-name='_ZN2B2C1Ev' filepath='../../prtests/test9.cc' line='45' column='3' declared-inline='yes' visibility='default' binding='weak' size-in-bits='8' alignment-in-bits='8'>
|
||||
<parameter type-id='type-id-10'/>
|
||||
<parameter type-id='type-id-9'/>
|
||||
<return type-id='type-id-1'/>
|
||||
</function-decl>
|
||||
</member-function>
|
||||
</class-decl>
|
||||
<class-decl name='S' visibility='default' is-declaration-only='yes' id='type-id-12'/>
|
||||
<pointer-type-def type-id='type-id-12' size-in-bits='64' alignment-in-bits='64' id='type-id-13'/>
|
||||
<class-decl name='S' size-in-bits='192' alignment-in-bits='64' visibility='default' filepath='../../prtests/test9.cc' line='58' column='7' id='type-id-14'>
|
||||
<class-decl name='S' visibility='default' is-declaration-only='yes' id='type-id-11'/>
|
||||
<pointer-type-def type-id='type-id-11' size-in-bits='64' alignment-in-bits='64' id='type-id-12'/>
|
||||
<class-decl name='S' size-in-bits='192' alignment-in-bits='64' visibility='default' filepath='../../prtests/test9.cc' line='58' column='7' id='type-id-13'>
|
||||
<base-class access='public' layout-offset-in-bits='64' type-id='type-id-5'/>
|
||||
<base-class access='public' layout-offset-in-bits='96' type-id='type-id-8'/>
|
||||
<base-class access='private' layout-offset-in-bits='160' is-virtual='yes' type-id='type-id-11'/>
|
||||
<base-class access='public' layout-offset-in-bits='96' type-id='type-id-6'/>
|
||||
<base-class access='private' layout-offset-in-bits='160' is-virtual='yes' type-id='type-id-10'/>
|
||||
<data-member access='private' layout-offset-in-bits='128'>
|
||||
<var-decl name='m0' type-id='type-id-2' visibility='default' filepath='../../prtests/test9.cc' line='60' column='7'/>
|
||||
</data-member>
|
||||
<member-function access='public'>
|
||||
<function-decl name='__comp_ctor ' mangled-name='_ZN1SC1Ev' filepath='../../prtests/test9.cc' line='64' column='3' declared-inline='yes' visibility='default' binding='weak' size-in-bits='8' alignment-in-bits='8'>
|
||||
<parameter type-id='type-id-13'/>
|
||||
<parameter type-id='type-id-12'/>
|
||||
<return type-id='type-id-1'/>
|
||||
</function-decl>
|
||||
</member-function>
|
||||
</class-decl>
|
||||
<class-decl name='__class_type_info_pseudo' size-in-bits='128' alignment-in-bits='64' visibility='default' id='type-id-15'/>
|
||||
<qualified-type-def type-id='type-id-15' const='yes' id='type-id-16'/>
|
||||
<var-decl name='_ZTI2B0' type-id='type-id-16' mangled-name='_ZTI2B0' visibility='default' binding='weak' filepath='../../prtests/test9.cc' line='81' column='1'/>
|
||||
<var-decl name='_ZTI2B2' type-id='type-id-16' mangled-name='_ZTI2B2' visibility='default' binding='weak' filepath='../../prtests/test9.cc' line='81' column='1'/>
|
||||
<var-decl name='_ZTI2B1' type-id='type-id-16' mangled-name='_ZTI2B1' visibility='default' binding='weak' filepath='../../prtests/test9.cc' line='81' column='1'/>
|
||||
<class-decl name='__vmi_class_type_info_pseudo3' size-in-bits='576' alignment-in-bits='64' visibility='default' id='type-id-17'/>
|
||||
<qualified-type-def type-id='type-id-17' const='yes' id='type-id-18'/>
|
||||
<var-decl name='_ZTI1S' type-id='type-id-18' mangled-name='_ZTI1S' visibility='default' binding='weak' filepath='../../prtests/test9.cc' line='58' column='7'/>
|
||||
<class-decl name='__class_type_info_pseudo' size-in-bits='128' alignment-in-bits='64' visibility='default' id='type-id-14'/>
|
||||
<qualified-type-def type-id='type-id-14' const='yes' id='type-id-15'/>
|
||||
<var-decl name='_ZTI2B0' type-id='type-id-15' mangled-name='_ZTI2B0' visibility='default' binding='weak' filepath='../../prtests/test9.cc' line='81' column='1'/>
|
||||
<var-decl name='_ZTI2B2' type-id='type-id-15' mangled-name='_ZTI2B2' visibility='default' binding='weak' filepath='../../prtests/test9.cc' line='81' column='1'/>
|
||||
<var-decl name='_ZTI2B1' type-id='type-id-15' mangled-name='_ZTI2B1' visibility='default' binding='weak' filepath='../../prtests/test9.cc' line='81' column='1'/>
|
||||
<class-decl name='__vmi_class_type_info_pseudo3' size-in-bits='576' alignment-in-bits='64' visibility='default' id='type-id-16'/>
|
||||
<qualified-type-def type-id='type-id-16' const='yes' id='type-id-17'/>
|
||||
<var-decl name='_ZTI1S' type-id='type-id-17' mangled-name='_ZTI1S' visibility='default' binding='weak' filepath='../../prtests/test9.cc' line='58' column='7'/>
|
||||
</abi-instr>
|
||||
|
Loading…
Reference in New Issue
Block a user