diff options
author | Dodji Seketeli <dodji@seketeli.org> | 2013-11-19 11:36:25 +0100 |
---|---|---|
committer | Dodji Seketeli <dodji@seketeli.org> | 2013-11-19 11:36:25 +0100 |
commit | ac1409d32a94cc3659138d91fa11743393de612b (patch) | |
tree | 578ed1dd68733a803c1db321bbcc0ae5452adc5c | |
parent | c0782449525d570bbd4972931d6e58458a159dcc (diff) | |
download | gcc-dodji/abi-instr.tar.gz |
Support for serialization of member typesdodji/abi-instr
cp/ChangeLog:
* abi-instr.cc (gen_scope_of): Member types are linked to their
scope via their DECL_CONTEXT (TYPE_NAME()), not their
TYPE_CONTEXT. <grin/>. Also, do not add empty elements to the
scope hash table.
(gen_scope_decl): Do not use a scope that is not yet fully built.
We should not be using gen_scope_decl while building type or decl
members. Rather, we should just be sticking the members into the
non-fully-built type/decl that we have at hand.
(gen_class_type_in_scope): Handle member types. Also, for member
functions, use the new (more generic) version of
abigail::add_decl_to_scope.
gcc/testsuite/ChangeLog:
* g++.dg/abi-dump/bases-0.C.bi: Update this for member type(def).
* g++.dg/abi-dump/simple-class-0.C.bi: Likewise.
-rw-r--r-- | gcc/cp/abi-instr.cc | 27 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi | 86 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi | 7 |
3 files changed, 77 insertions, 43 deletions
diff --git a/gcc/cp/abi-instr.cc b/gcc/cp/abi-instr.cc index ac697003e10..fe3b9823913 100644 --- a/gcc/cp/abi-instr.cc +++ b/gcc/cp/abi-instr.cc @@ -270,7 +270,7 @@ gen_scope_of (const_tree t) tree context = NULL_TREE; if (TYPE_P (t)) - context = TYPE_CONTEXT (t); + context = TYPE_NAME (t) ? DECL_CONTEXT (TYPE_NAME (t)) : TYPE_CONTEXT (t); else if (DECL_P (t)) context = DECL_CONTEXT (t); @@ -287,7 +287,8 @@ gen_scope_of (const_tree t) result = gen_scope_decl (context, gen_scope_of (context)); - m[t] = result; + if (result) + m[t] = result; return result; } @@ -607,7 +608,17 @@ gen_scope_decl (const_tree t, add_decl_to_scope (result, scope); } else if (TREE_CODE (t) == RECORD_TYPE) - result = gen_class_type_in_scope (t, scope); + { + abigail::class_decl_sptr cl = gen_class_type_in_scope (t, scope); + if (cl->is_declaration_only()) + // This means that t is part of a class scope that is + // currently being defined. So we cannot yet use that scope + // to e.g add stuff into it. So let's just bail out for the + // moment. + ; + else + result = cl; + } else gcc_unreachable (); @@ -816,6 +827,14 @@ gen_class_type_in_scope (const_tree t, gen_data_member (m); if (member) class_type->add_data_member (member); + else if (TREE_CODE (m) == TYPE_DECL) + { + abigail::type_base_sptr ty = + gen_type_in_scope(TREE_TYPE (m), abigail::scope_decl_sptr ()); + if (ty) + class_type->add_member_type (ty, get_access (TREE_TYPE (m))); + } + // else, handle the other kinds of members here. } for (tree m = TYPE_METHODS (t); m; m = DECL_CHAIN (m)) @@ -825,7 +844,7 @@ gen_class_type_in_scope (const_tree t, shared_ptr <abigail::class_decl::member_function> member = gen_member_function (m, class_type); if (member) - class_type->add_member_function (member); + add_decl_to_scope(member, class_type); } } diff --git a/gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi b/gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi index c121a989966..25940c0c4e9 100644 --- a/gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi +++ b/gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi @@ -9,6 +9,9 @@ <qualified-type-def type-id='type-id-3' const='yes' filepath='bases-0.C' line='5' column='7' id='type-id-5'/> <pointer-type-def type-id='type-id-5' size-in-bits='64' alignment-in-bits='64' id='type-id-6'/> <class-decl name='B0' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='bases-0.C' line='5' column='7' def-of-decl-id='type-id-3' id='type-id-7'> + <member-type access='public'> + <typedef-decl name='B0' type-id='type-id-3' filepath='bases-0.C' line='6' column='1' id='type-id-8'/> + </member-type> <data-member access='private' layout-offset-in-bits='0'> <var-decl name='m0' type-id='type-id-2' visibility='default' filepath='bases-0.C' line='7' column='7'/> </data-member> @@ -38,121 +41,130 @@ </function-decl> </member-function> </class-decl> - <class-decl name='B1' 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'/> - <qualified-type-def type-id='type-id-8' const='yes' filepath='bases-0.C' line='37' column='7' id='type-id-10'/> - <pointer-type-def type-id='type-id-10' size-in-bits='64' alignment-in-bits='64' id='type-id-11'/> - <class-decl name='B1' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='bases-0.C' line='37' column='7' def-of-decl-id='type-id-8' id='type-id-12'> + <class-decl name='B1' 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'/> + <qualified-type-def type-id='type-id-9' const='yes' filepath='bases-0.C' line='37' column='7' 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='B1' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='bases-0.C' line='37' column='7' def-of-decl-id='type-id-9' id='type-id-13'> + <member-type access='public'> + <typedef-decl name='B1' type-id='type-id-9' filepath='bases-0.C' line='38' column='1' id='type-id-14'/> + </member-type> <data-member access='private' layout-offset-in-bits='0'> <var-decl name='m0' type-id='type-id-2' visibility='default' filepath='bases-0.C' line='39' column='7'/> </data-member> <member-function access='public' constructor='yes'> <function-decl name='__base_ctor ' mangled-name='_ZN2B1C2Ev' filepath='bases-0.C' line='52' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-9'/> + <parameter type-id='type-id-10'/> <return type-id='type-id-1'/> </function-decl> </member-function> <member-function access='public' constructor='yes'> <function-decl name='__comp_ctor ' mangled-name='_ZN2B1C1Ev' filepath='bases-0.C' line='52' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-9'/> + <parameter type-id='type-id-10'/> <return type-id='type-id-1'/> </function-decl> </member-function> <member-function access='public' const='yes'> <function-decl name='get_m0' mangled-name='_ZNK2B16get_m0Ev' filepath='bases-0.C' line='58' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-11'/> + <parameter type-id='type-id-12'/> <return type-id='type-id-2'/> </function-decl> </member-function> <member-function access='public'> <function-decl name='set_m0' mangled-name='_ZN2B16set_m0Ei' filepath='bases-0.C' line='64' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-9'/> + <parameter type-id='type-id-10'/> <parameter type-id='type-id-2'/> <return type-id='type-id-1'/> </function-decl> </member-function> </class-decl> - <class-decl name='B2' visibility='default' is-declaration-only='yes' id='type-id-13'/> - <pointer-type-def type-id='type-id-13' size-in-bits='64' alignment-in-bits='64' id='type-id-14'/> - <qualified-type-def type-id='type-id-13' const='yes' filepath='bases-0.C' line='69' column='7' id='type-id-15'/> + <class-decl name='B2' visibility='default' is-declaration-only='yes' id='type-id-15'/> <pointer-type-def type-id='type-id-15' size-in-bits='64' alignment-in-bits='64' id='type-id-16'/> - <class-decl name='B2' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='bases-0.C' line='69' column='7' def-of-decl-id='type-id-13' id='type-id-17'> + <qualified-type-def type-id='type-id-15' const='yes' filepath='bases-0.C' line='69' column='7' id='type-id-17'/> + <pointer-type-def type-id='type-id-17' size-in-bits='64' alignment-in-bits='64' id='type-id-18'/> + <class-decl name='B2' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='bases-0.C' line='69' column='7' def-of-decl-id='type-id-15' id='type-id-19'> + <member-type access='public'> + <typedef-decl name='B2' type-id='type-id-15' filepath='bases-0.C' line='70' column='1' id='type-id-20'/> + </member-type> <data-member access='private' layout-offset-in-bits='0'> <var-decl name='m0' type-id='type-id-2' visibility='default' filepath='bases-0.C' line='71' column='7'/> </data-member> <member-function access='public' constructor='yes'> <function-decl name='__base_ctor ' mangled-name='_ZN2B2C2Ev' filepath='bases-0.C' line='84' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-14'/> + <parameter type-id='type-id-16'/> <return type-id='type-id-1'/> </function-decl> </member-function> <member-function access='public' constructor='yes'> <function-decl name='__comp_ctor ' mangled-name='_ZN2B2C1Ev' filepath='bases-0.C' line='84' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-14'/> + <parameter type-id='type-id-16'/> <return type-id='type-id-1'/> </function-decl> </member-function> <member-function access='public' const='yes'> <function-decl name='get_m0' mangled-name='_ZNK2B26get_m0Ev' filepath='bases-0.C' line='90' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-16'/> + <parameter type-id='type-id-18'/> <return type-id='type-id-2'/> </function-decl> </member-function> <member-function access='public'> <function-decl name='set_m0' mangled-name='_ZN2B26set_m0Ei' filepath='bases-0.C' line='96' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-14'/> + <parameter type-id='type-id-16'/> <parameter type-id='type-id-2'/> <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-18'/> - <pointer-type-def type-id='type-id-18' size-in-bits='64' alignment-in-bits='64' id='type-id-19'/> - <qualified-type-def type-id='type-id-1' const='yes' id='type-id-20'/> - <pointer-type-def type-id='type-id-20' size-in-bits='64' alignment-in-bits='64' id='type-id-21'/> + <class-decl name='S' visibility='default' is-declaration-only='yes' id='type-id-21'/> <pointer-type-def type-id='type-id-21' size-in-bits='64' alignment-in-bits='64' id='type-id-22'/> - <qualified-type-def type-id='type-id-18' const='yes' filepath='bases-0.C' line='101' column='7' id='type-id-23'/> + <qualified-type-def type-id='type-id-1' const='yes' id='type-id-23'/> <pointer-type-def type-id='type-id-23' size-in-bits='64' alignment-in-bits='64' id='type-id-24'/> - <class-decl name='S' size-in-bits='192' alignment-in-bits='64' visibility='default' filepath='bases-0.C' line='101' column='7' def-of-decl-id='type-id-18' id='type-id-25'> + <pointer-type-def type-id='type-id-24' size-in-bits='64' alignment-in-bits='64' id='type-id-25'/> + <qualified-type-def type-id='type-id-21' const='yes' filepath='bases-0.C' line='101' column='7' id='type-id-26'/> + <pointer-type-def type-id='type-id-26' size-in-bits='64' alignment-in-bits='64' id='type-id-27'/> + <class-decl name='S' size-in-bits='192' alignment-in-bits='64' visibility='default' filepath='bases-0.C' line='101' column='7' def-of-decl-id='type-id-21' id='type-id-28'> <base-class access='public' layout-offset-in-bits='64' type-id='type-id-7'/> - <base-class access='public' layout-offset-in-bits='96' type-id='type-id-12'/> - <base-class access='private' layout-offset-in-bits='160' is-virtual='yes' type-id='type-id-17'/> + <base-class access='public' layout-offset-in-bits='96' type-id='type-id-13'/> + <base-class access='private' layout-offset-in-bits='160' is-virtual='yes' type-id='type-id-19'/> + <member-type access='public'> + <typedef-decl name='S' type-id='type-id-21' filepath='bases-0.C' line='102' column='1' id='type-id-29'/> + </member-type> <data-member access='private' layout-offset-in-bits='128'> <var-decl name='m0' type-id='type-id-2' visibility='default' filepath='bases-0.C' line='103' column='7'/> </data-member> <member-function access='public' constructor='yes'> <function-decl name='__base_ctor ' mangled-name='_ZN1SC2Ev' filepath='bases-0.C' line='116' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-19'/> <parameter type-id='type-id-22'/> + <parameter type-id='type-id-25'/> <return type-id='type-id-1'/> </function-decl> </member-function> <member-function access='public' constructor='yes'> <function-decl name='__comp_ctor ' mangled-name='_ZN1SC1Ev' filepath='bases-0.C' line='116' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-19'/> + <parameter type-id='type-id-22'/> <return type-id='type-id-1'/> </function-decl> </member-function> <member-function access='public' const='yes'> <function-decl name='get_m0' mangled-name='_ZNK1S6get_m0Ev' filepath='bases-0.C' line='122' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-24'/> + <parameter type-id='type-id-27'/> <return type-id='type-id-2'/> </function-decl> </member-function> <member-function access='public'> <function-decl name='set_m0' mangled-name='_ZN1S6set_m0Ei' filepath='bases-0.C' line='128' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-19'/> + <parameter type-id='type-id-22'/> <parameter type-id='type-id-2'/> <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-26'/> - <qualified-type-def type-id='type-id-26' const='yes' id='type-id-27'/> - <var-decl name='_ZTI2B0' type-id='type-id-27' mangled-name='_ZTI2B0' visibility='default' binding='weak' filepath='bases-0.C' line='137' column='1'/> - <var-decl name='_ZTI2B2' type-id='type-id-27' mangled-name='_ZTI2B2' visibility='default' binding='weak' filepath='bases-0.C' line='137' column='1'/> - <var-decl name='_ZTI2B1' type-id='type-id-27' mangled-name='_ZTI2B1' visibility='default' binding='weak' filepath='bases-0.C' line='137' column='1'/> - <class-decl name='__vmi_class_type_info_pseudo3' size-in-bits='576' alignment-in-bits='64' visibility='default' id='type-id-28'/> - <qualified-type-def type-id='type-id-28' const='yes' id='type-id-29'/> - <var-decl name='_ZTI1S' type-id='type-id-29' mangled-name='_ZTI1S' visibility='default' binding='weak' filepath='bases-0.C' line='101' column='7'/> + <class-decl name='__class_type_info_pseudo' size-in-bits='128' alignment-in-bits='64' visibility='default' id='type-id-30'/> + <qualified-type-def type-id='type-id-30' const='yes' id='type-id-31'/> + <var-decl name='_ZTI2B0' type-id='type-id-31' mangled-name='_ZTI2B0' visibility='default' binding='weak' filepath='bases-0.C' line='137' column='1'/> + <var-decl name='_ZTI2B2' type-id='type-id-31' mangled-name='_ZTI2B2' visibility='default' binding='weak' filepath='bases-0.C' line='137' column='1'/> + <var-decl name='_ZTI2B1' type-id='type-id-31' mangled-name='_ZTI2B1' visibility='default' binding='weak' filepath='bases-0.C' line='137' column='1'/> + <class-decl name='__vmi_class_type_info_pseudo3' size-in-bits='576' alignment-in-bits='64' visibility='default' id='type-id-32'/> + <qualified-type-def type-id='type-id-32' const='yes' id='type-id-33'/> + <var-decl name='_ZTI1S' type-id='type-id-33' mangled-name='_ZTI1S' visibility='default' binding='weak' filepath='bases-0.C' line='101' column='7'/> </abi-instr> diff --git a/gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi b/gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi index 9d04b298ddd..77733063ff3 100644 --- a/gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi +++ b/gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi @@ -6,6 +6,9 @@ <qualified-type-def type-id='type-id-2' const='yes' filepath='simple-class-0.C' line='5' column='8' id='type-id-5'/> <reference-type-def kind='lvalue' type-id='type-id-5' size-in-bits='64' alignment-in-bits='64' id='type-id-6'/> <class-decl name='S' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='simple-class-0.C' line='5' column='8' def-of-decl-id='type-id-2' id='type-id-7'> + <member-type access='public'> + <typedef-decl name='S' type-id='type-id-2' filepath='simple-class-0.C' line='6' column='1' id='type-id-8'/> + </member-type> <data-member access='public' layout-offset-in-bits='0'> <var-decl name='m' type-id='type-id-1' visibility='default' filepath='simple-class-0.C' line='7' column='7'/> </data-member> @@ -36,9 +39,9 @@ </function-decl> </member-function> </class-decl> - <reference-type-def kind='lvalue' type-id='type-id-7' size-in-bits='64' alignment-in-bits='64' id='type-id-8'/> + <reference-type-def kind='lvalue' type-id='type-id-7' size-in-bits='64' alignment-in-bits='64' id='type-id-9'/> <function-decl name='foo' mangled-name='_Z3fooR1S' filepath='simple-class-0.C' line='24' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'> - <parameter type-id='type-id-8'/> + <parameter type-id='type-id-9'/> <return type-id='type-id-4'/> </function-decl> </abi-instr> |