Commit 911a71a7 by Mark Mitchell Committed by Mark Mitchell

Allow indirect primary bases.

	* cp-tree.h (struct lang_type): Remove vfield_parent.  Add
	primary_base.
	(CLASSTYPE_VFIELD_PARENT): Remove.
	(CLASSTYPE_PRIMARY_BINFO): Reimplement.
	(BINFO_PRIMARY_BINFO): Remove.
	(CLASSTYPE_HAS_PRIMARY_BASE_P): Reimplement.
	(BINFO_VBASE_PRIMARY_P): Likewise.
	(BINFO_PRIMARY_BASE_OF): New macro.
	(BINFO_INDIRECT_PRIMARY_P): Likewise.
	(get_primary_binfo): New function.
	* decl.c (lang_mark_tree): Make lang_type::primary_base.
	* class.c (vcall_offset_data_s): Rename to ...
	(vtbl_init_data_s): ... this.  Rename primary_p to primary_vtbl_p,
	and add ctor_vtbl_p.
	(get_derived_offset): Use get_primary_binfo.
	(dfs_mark_primary_bases): Adjust handling of virtual primary
	bases.
	(mark_primary_bases): Likewise.
	(set_primary_base): Take a binfo, not an integer, as a
	representation of the primary base.
	(indirect_primary_base_p): Remove.
	(determine_primary_base): Adjust for indirect primary bases.
	(dfs_find_final_overrider): Fix typo in coment.
	(update_vtable_entry_for_fn): Use get_primary_binfo.
	(layout_nonempty_base_or_field): Tweak.
	(build_base_fields): Adjust for new primary base semantics.
	(dfs_propagate_binfo_offsets): Remove.
	(propagate_binfo_offsets): Rewrite.
	(dfs_set_offset_for_shared_vbases): Remove.
	(layout_virtual_bases): Don't use it.
	(layout_class_type): Set CLASSTYPE_SIZE correctly under the new
	ABI.
	(finish_struct_1): Set CLASSTYPE_PRIMARY_BINFO, not
	CLASSTYPE_VFIELD_PARENT.
	(dfs_get_primary_binfo): New function.
	(get_primary_binfo): Likewise.
	(dump_class_hierarchy_r): Tweak printing of primary bases.
	(build_vtbl_initializer): Fix typo in comments.  Use
	vtbl_init_data.
	(build_vcall_and_vbase_vtbl_entries): Likewise.
	(build_vbaes_offset_vtbl_entries): Likewise.
	(dfs_build_vcall_offset_vtbl_entries): Adjust setting of
	BV_VCALL_INDEX to handle indirect primary bases.
	(build_vcall_offset_vtbl_entries): Use vtbl_init_data.
	(build_rtti_vtbl_entries): Likewise.
	* search.c (get_shared_vbase_if_not_primary): Tweak.
	(find_vbase_instance): Likewise.
	(binfo_for_vtable): Simplify.
	* tree.c (unshare_base_binfos): Clear BINFO_PRIMARY_BASE_OF.
	(make_binfo): Make it have 11 entries.

From-SVN: r35360
parent abe24fb3
2000-07-30 Mark Mitchell <mark@codesourcery.com>
Allow indirect primary bases.
* cp-tree.h (struct lang_type): Remove vfield_parent. Add
primary_base.
(CLASSTYPE_VFIELD_PARENT): Remove.
(CLASSTYPE_PRIMARY_BINFO): Reimplement.
(BINFO_PRIMARY_BINFO): Remove.
(CLASSTYPE_HAS_PRIMARY_BASE_P): Reimplement.
(BINFO_VBASE_PRIMARY_P): Likewise.
(BINFO_PRIMARY_BASE_OF): New macro.
(BINFO_INDIRECT_PRIMARY_P): Likewise.
(get_primary_binfo): New function.
* decl.c (lang_mark_tree): Make lang_type::primary_base.
* class.c (vcall_offset_data_s): Rename to ...
(vtbl_init_data_s): ... this. Rename primary_p to primary_vtbl_p,
and add ctor_vtbl_p.
(get_derived_offset): Use get_primary_binfo.
(dfs_mark_primary_bases): Adjust handling of virtual primary
bases.
(mark_primary_bases): Likewise.
(set_primary_base): Take a binfo, not an integer, as a
representation of the primary base.
(indirect_primary_base_p): Remove.
(determine_primary_base): Adjust for indirect primary bases.
(dfs_find_final_overrider): Fix typo in coment.
(update_vtable_entry_for_fn): Use get_primary_binfo.
(layout_nonempty_base_or_field): Tweak.
(build_base_fields): Adjust for new primary base semantics.
(dfs_propagate_binfo_offsets): Remove.
(propagate_binfo_offsets): Rewrite.
(dfs_set_offset_for_shared_vbases): Remove.
(layout_virtual_bases): Don't use it.
(layout_class_type): Set CLASSTYPE_SIZE correctly under the new
ABI.
(finish_struct_1): Set CLASSTYPE_PRIMARY_BINFO, not
CLASSTYPE_VFIELD_PARENT.
(dfs_get_primary_binfo): New function.
(get_primary_binfo): Likewise.
(dump_class_hierarchy_r): Tweak printing of primary bases.
(build_vtbl_initializer): Fix typo in comments. Use
vtbl_init_data.
(build_vcall_and_vbase_vtbl_entries): Likewise.
(build_vbaes_offset_vtbl_entries): Likewise.
(dfs_build_vcall_offset_vtbl_entries): Adjust setting of
BV_VCALL_INDEX to handle indirect primary bases.
(build_vcall_offset_vtbl_entries): Use vtbl_init_data.
(build_rtti_vtbl_entries): Likewise.
* search.c (get_shared_vbase_if_not_primary): Tweak.
(find_vbase_instance): Likewise.
(binfo_for_vtable): Simplify.
* tree.c (unshare_base_binfos): Clear BINFO_PRIMARY_BASE_OF.
(make_binfo): Make it have 11 entries.
2000-07-30 Alex Samuel <samuel@codesourcery.com> 2000-07-30 Alex Samuel <samuel@codesourcery.com>
* mangle.c (DECL_TEMPLATE_ID_P): Remove. * mangle.c (DECL_TEMPLATE_ID_P): Remove.
......
...@@ -69,9 +69,8 @@ Boston, MA 02111-1307, USA. */ ...@@ -69,9 +69,8 @@ Boston, MA 02111-1307, USA. */
or FIELD_DECL). or FIELD_DECL).
NEED_TEMPORARY_P (in REF_BIND, BASE_CONV) NEED_TEMPORARY_P (in REF_BIND, BASE_CONV)
IDENTIFIER_TYPENAME_P (in IDENTIFIER_NODE) IDENTIFIER_TYPENAME_P (in IDENTIFIER_NODE)
5: BINFO_PRIMARY_MARKED_P (in BINFO) 5: Unused.
6: BINFO_VBASE_PRIMARY_P (in BINFO) 6: BINFO_ACCESS (in BINFO)
BINFO_ACCESS (in BINFO)
Usage of TYPE_LANG_FLAG_?: Usage of TYPE_LANG_FLAG_?:
0: C_TYPE_FIELDS_READONLY (in RECORD_TYPE or UNION_TYPE). 0: C_TYPE_FIELDS_READONLY (in RECORD_TYPE or UNION_TYPE).
...@@ -100,7 +99,10 @@ Boston, MA 02111-1307, USA. */ ...@@ -100,7 +99,10 @@ Boston, MA 02111-1307, USA. */
DECL_THUNK_P (in a member FUNCTION_DECL) DECL_THUNK_P (in a member FUNCTION_DECL)
Usage of language-independent fields in a language-dependent manner: Usage of language-independent fields in a language-dependent manner:
TREE_USED
This field is BINFO_INDIRECT_PRIMARY_P in a BINFO.
TYPE_ALIAS_SET TYPE_ALIAS_SET
This field is used by TYPENAME_TYPEs, TEMPLATE_TYPE_PARMs, and so This field is used by TYPENAME_TYPEs, TEMPLATE_TYPE_PARMs, and so
forth as a substitute for the mark bits provided in `lang_type'. forth as a substitute for the mark bits provided in `lang_type'.
...@@ -1391,8 +1393,8 @@ struct lang_type ...@@ -1391,8 +1393,8 @@ struct lang_type
unsigned dummy : 8; unsigned dummy : 8;
int vsize; int vsize;
int vfield_parent;
tree primary_base;
tree vfields; tree vfields;
tree vbases; tree vbases;
tree tags; tree tags;
...@@ -1562,34 +1564,16 @@ struct lang_type ...@@ -1562,34 +1564,16 @@ struct lang_type
nested member class templates. */ nested member class templates. */
#define CLASSTYPE_TAGS(NODE) (TYPE_LANG_SPECIFIC(NODE)->tags) #define CLASSTYPE_TAGS(NODE) (TYPE_LANG_SPECIFIC(NODE)->tags)
/* If this value is non-negative, it is the index (in the
TYPE_BINFO_BASETYPES) for the base-class whose vtable pointer we
are reusing. For example, in D : B1, B2, PARENT would be 0, if D's
vtable came from B1, 1, if D's vtable came from B2. */
#define CLASSTYPE_VFIELD_PARENT(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfield_parent)
/* Nonzero if NODE has a primary base class, i.e., a base class with /* Nonzero if NODE has a primary base class, i.e., a base class with
which it shares the virtual fucntion table pointer. */ which it shares the virtual fucntion table pointer. */
#define CLASSTYPE_HAS_PRIMARY_BASE_P(NODE) \ #define CLASSTYPE_HAS_PRIMARY_BASE_P(NODE) \
(CLASSTYPE_VFIELD_PARENT (NODE) != -1) (CLASSTYPE_PRIMARY_BINFO (NODE) != NULL_TREE)
/* If non-NULL, this is the binfo for the primary base class, i.e., /* If non-NULL, this is the binfo for the primary base class, i.e.,
the base class which contains the virtual function table pointer the base class which contains the virtual function table pointer
for this class. */ for this class. */
#define CLASSTYPE_PRIMARY_BINFO(NODE) \ #define CLASSTYPE_PRIMARY_BINFO(NODE) \
(BINFO_PRIMARY_BINFO (TYPE_BINFO (NODE))) (TYPE_LANG_SPECIFIC (NODE)->primary_base)
/* If non-NULL, this is the binfo for the primary base of BINFO. Note
that in a complex hierarchy the resulting BINFO may not actually
*be* primary. In particular if the resulting BINFO is a virtual
base, and it occurs elsewhere in the hierarchy, then this
occurrence may not actually be a primary base in the complete
object. Check BINFO_PRIMARY_MARKED_P to be sure. */
#define BINFO_PRIMARY_BINFO(NODE) \
(CLASSTYPE_HAS_PRIMARY_BASE_P (BINFO_TYPE (NODE)) \
? BINFO_BASETYPE (NODE, \
CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (NODE))) \
: NULL_TREE)
/* The number of virtual functions present in this class' virtual /* The number of virtual functions present in this class' virtual
function table. */ function table. */
...@@ -1752,11 +1736,8 @@ struct lang_type ...@@ -1752,11 +1736,8 @@ struct lang_type
class of a non-primary virtual base. This flag is only valid for class of a non-primary virtual base. This flag is only valid for
paths (given by BINFO_INHERITANCE_CHAIN) that really exist in the paths (given by BINFO_INHERITANCE_CHAIN) that really exist in the
final object. */ final object. */
#define BINFO_PRIMARY_MARKED_P(NODE) TREE_LANG_FLAG_5 (NODE) #define BINFO_PRIMARY_MARKED_P(NODE) \
(BINFO_PRIMARY_BASE_OF (NODE) != NULL_TREE)
/* Nonzero if the virtual baseclass with the type given by this BINFO
is primary *somewhere* in the hierarchy. */
#define BINFO_VBASE_PRIMARY_P(NODE) TREE_LANG_FLAG_6 (NODE)
/* The index in the VTT where this subobject's sub-VTT can be found. /* The index in the VTT where this subobject's sub-VTT can be found.
NULL_TREE if there is no sub-VTT. */ NULL_TREE if there is no sub-VTT. */
...@@ -1766,10 +1747,21 @@ struct lang_type ...@@ -1766,10 +1747,21 @@ struct lang_type
found. NULL_TREE if there is no secondary vptr in the VTT. */ found. NULL_TREE if there is no secondary vptr in the VTT. */
#define BINFO_VPTR_INDEX(NODE) TREE_VEC_ELT ((NODE), 9) #define BINFO_VPTR_INDEX(NODE) TREE_VEC_ELT ((NODE), 9)
/* The binfo of which NODE is a primary base. (This is different from
BINFO_INHERITANCE_CHAIN for virtual base because a virtual base is
sometimes a primary base for a class for which it is not an
immediate base.) */
#define BINFO_PRIMARY_BASE_OF(NODE) TREE_VEC_ELT ((NODE), 10)
/* Nonzero if this binfo declares a virtual function which is /* Nonzero if this binfo declares a virtual function which is
overridden along a virtual path. */ overridden along a virtual path. */
#define BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P(NODE) TREE_LANG_FLAG_2 (NODE) #define BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P(NODE) TREE_LANG_FLAG_2 (NODE)
/* Nonzero if this binfo is an indirect primary base, i.e. a virtual
base that is a primary base of some of other class in the
hierarchy. */
#define BINFO_INDIRECT_PRIMARY_P(NODE) TREE_USED (NODE)
/* Used by various search routines. */ /* Used by various search routines. */
#define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE) #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE)
...@@ -3844,6 +3836,7 @@ extern void note_name_declared_in_class PARAMS ((tree, tree)); ...@@ -3844,6 +3836,7 @@ extern void note_name_declared_in_class PARAMS ((tree, tree));
extern tree get_vtbl_decl_for_binfo PARAMS ((tree)); extern tree get_vtbl_decl_for_binfo PARAMS ((tree));
extern tree in_charge_arg_for_name PARAMS ((tree)); extern tree in_charge_arg_for_name PARAMS ((tree));
extern tree get_vtt_name PARAMS ((tree)); extern tree get_vtt_name PARAMS ((tree));
extern tree get_primary_binfo PARAMS ((tree));
/* in cvt.c */ /* in cvt.c */
extern tree convert_to_reference PARAMS ((tree, tree, int, int, tree)); extern tree convert_to_reference PARAMS ((tree, tree, int, int, tree));
......
...@@ -15007,6 +15007,7 @@ lang_mark_tree (t) ...@@ -15007,6 +15007,7 @@ lang_mark_tree (t)
&& TREE_CODE (TREE_TYPE (t)) == METHOD_TYPE)) && TREE_CODE (TREE_TYPE (t)) == METHOD_TYPE))
{ {
ggc_mark (lt); ggc_mark (lt);
ggc_mark_tree (lt->primary_base);
ggc_mark_tree (lt->vfields); ggc_mark_tree (lt->vfields);
ggc_mark_tree (lt->vbases); ggc_mark_tree (lt->vbases);
ggc_mark_tree (lt->tags); ggc_mark_tree (lt->tags);
......
...@@ -2199,7 +2199,7 @@ get_shared_vbase_if_not_primary (binfo, data) ...@@ -2199,7 +2199,7 @@ get_shared_vbase_if_not_primary (binfo, data)
/* This is a non-primary virtual base. If there is no primary /* This is a non-primary virtual base. If there is no primary
version, get the shared version. */ version, get the shared version. */
binfo = binfo_for_vbase (BINFO_TYPE (binfo), type); binfo = binfo_for_vbase (BINFO_TYPE (binfo), type);
if (BINFO_VBASE_PRIMARY_P (binfo)) if (BINFO_PRIMARY_MARKED_P (binfo))
return NULL_TREE; return NULL_TREE;
} }
...@@ -2883,7 +2883,7 @@ find_vbase_instance (base, type) ...@@ -2883,7 +2883,7 @@ find_vbase_instance (base, type)
tree instance; tree instance;
instance = binfo_for_vbase (base, type); instance = binfo_for_vbase (base, type);
if (!BINFO_VBASE_PRIMARY_P (instance)) if (!BINFO_PRIMARY_MARKED_P (instance))
return instance; return instance;
return dfs_walk (TYPE_BINFO (type), return dfs_walk (TYPE_BINFO (type),
...@@ -3357,21 +3357,9 @@ binfo_for_vtable (var) ...@@ -3357,21 +3357,9 @@ binfo_for_vtable (var)
tree var; tree var;
{ {
tree binfo = TYPE_BINFO (DECL_CONTEXT (var)); tree binfo = TYPE_BINFO (DECL_CONTEXT (var));
tree binfos;
int i;
while (1) while (CLASSTYPE_HAS_PRIMARY_BASE_P (BINFO_TYPE (binfo)))
{ binfo = get_primary_binfo (binfo);
binfos = BINFO_BASETYPES (binfo);
if (binfos == NULL_TREE)
break;
i = CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
if (i == -1)
break;
binfo = TREE_VEC_ELT (binfos, i);
}
return binfo; return binfo;
} }
......
...@@ -687,6 +687,7 @@ unshare_base_binfos (binfo) ...@@ -687,6 +687,7 @@ unshare_base_binfos (binfo)
TREE_VIA_PROTECTED (new_binfo) = TREE_VIA_PROTECTED (base_binfo); TREE_VIA_PROTECTED (new_binfo) = TREE_VIA_PROTECTED (base_binfo);
TREE_VIA_VIRTUAL (new_binfo) = TREE_VIA_VIRTUAL (base_binfo); TREE_VIA_VIRTUAL (new_binfo) = TREE_VIA_VIRTUAL (base_binfo);
BINFO_INHERITANCE_CHAIN (new_binfo) = binfo; BINFO_INHERITANCE_CHAIN (new_binfo) = binfo;
BINFO_PRIMARY_BASE_OF (new_binfo) = NULL_TREE;
unshare_base_binfos (new_binfo); unshare_base_binfos (new_binfo);
} }
} }
...@@ -851,7 +852,7 @@ make_binfo (offset, binfo, vtable, virtuals) ...@@ -851,7 +852,7 @@ make_binfo (offset, binfo, vtable, virtuals)
tree offset, binfo; tree offset, binfo;
tree vtable, virtuals; tree vtable, virtuals;
{ {
tree new_binfo = make_tree_vec (10); tree new_binfo = make_tree_vec (11);
tree type; tree type;
if (TREE_CODE (binfo) == TREE_VEC) if (TREE_CODE (binfo) == TREE_VEC)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment