Commit 23381155 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (CLASSTYPE_VBASECLASSES): Update documentation.

	* cp-tree.h (CLASSTYPE_VBASECLASSES): Update documentation.
	(CLASSTYPE_N_BASECLASSES): Likewise.
	(BINFO_FOR_VBASE): New macro.
	(get_vbase_types): Change prototype.
	* class.c (build_vbase_path): Use BINFO_FOR_VBASE.
	(prepare_fresh_vtable): Likewise.
	(finish_vtbls): Likewise.
	(get_class_offset_1): Likewise.
	(modify_all_indirect_vtables): Likewise.
	(build_vbase_pointer_fields): Likewise.
	* decl.c (xref_basetypes): Don't set CLASSTYPE_VBASECLASSES here.
	* init.c (sort_base_init): Use BINFO_FOR_VBASE.
	(expand_member_init): Likewise.
	* search.c (get_base_distance): Likewise.
	(lookup_field_queue_p): Likewise.
	(virtual_context): Likewise.
	(get_vbase_types): Don't return a value.  Set
	CLASSTYPE_VBASECLASSES here.
	* typeck.c (get_delta_difference): Use BINFO_FOR_VBASE.

From-SVN: r31150
parent 8b4d03b1
1999-12-31 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (CLASSTYPE_VBASECLASSES): Update documentation.
(CLASSTYPE_N_BASECLASSES): Likewise.
(BINFO_FOR_VBASE): New macro.
(get_vbase_types): Change prototype.
* class.c (build_vbase_path): Use BINFO_FOR_VBASE.
(prepare_fresh_vtable): Likewise.
(finish_vtbls): Likewise.
(get_class_offset_1): Likewise.
(modify_all_indirect_vtables): Likewise.
(build_vbase_pointer_fields): Likewise.
* decl.c (xref_basetypes): Don't set CLASSTYPE_VBASECLASSES here.
* init.c (sort_base_init): Use BINFO_FOR_VBASE.
(expand_member_init): Likewise.
* search.c (get_base_distance): Likewise.
(lookup_field_queue_p): Likewise.
(virtual_context): Likewise.
(get_vbase_types): Don't return a value. Set
CLASSTYPE_VBASECLASSES here.
* typeck.c (get_delta_difference): Use BINFO_FOR_VBASE.
1999-12-30 Mark Mitchell <mark@codesourcery.com> 1999-12-30 Mark Mitchell <mark@codesourcery.com>
* class.c (fixup_inline_methods): Clear CLASSTYPE_INLINE_FRIENDS. * class.c (fixup_inline_methods): Clear CLASSTYPE_INLINE_FRIENDS.
......
...@@ -331,8 +331,8 @@ build_vbase_path (code, type, expr, path, nonnull) ...@@ -331,8 +331,8 @@ build_vbase_path (code, type, expr, path, nonnull)
{ {
if (last_virtual) if (last_virtual)
{ {
offset = BINFO_OFFSET (binfo_member (last_virtual, offset = BINFO_OFFSET (BINFO_FOR_VBASE (last_virtual,
CLASSTYPE_VBASECLASSES (basetype))); basetype));
offset = size_binop (PLUS_EXPR, offset, BINFO_OFFSET (last)); offset = size_binop (PLUS_EXPR, offset, BINFO_OFFSET (last));
} }
else else
...@@ -884,8 +884,7 @@ prepare_fresh_vtable (binfo, for_type) ...@@ -884,8 +884,7 @@ prepare_fresh_vtable (binfo, for_type)
if (TREE_VIA_VIRTUAL (binfo)) if (TREE_VIA_VIRTUAL (binfo))
{ {
tree binfo1 = binfo_member (BINFO_TYPE (binfo), tree binfo1 = BINFO_FOR_VBASE (BINFO_TYPE (binfo), for_type);
CLASSTYPE_VBASECLASSES (for_type));
/* XXX - This should never happen, if it does, the caller should /* XXX - This should never happen, if it does, the caller should
ensure that the binfo is from for_type's binfos, not from any ensure that the binfo is from for_type's binfos, not from any
...@@ -911,8 +910,8 @@ prepare_fresh_vtable (binfo, for_type) ...@@ -911,8 +910,8 @@ prepare_fresh_vtable (binfo, for_type)
import_export_vtable (new_decl, for_type, 0); import_export_vtable (new_decl, for_type, 0);
if (TREE_VIA_VIRTUAL (binfo)) if (TREE_VIA_VIRTUAL (binfo))
my_friendly_assert (binfo == binfo_member (BINFO_TYPE (binfo), my_friendly_assert (binfo == BINFO_FOR_VBASE (BINFO_TYPE (binfo),
CLASSTYPE_VBASECLASSES (current_class_type)), current_class_type),
170); 170);
SET_BINFO_NEW_VTABLE_MARKED (binfo); SET_BINFO_NEW_VTABLE_MARKED (binfo);
} }
...@@ -2321,8 +2320,7 @@ finish_vtbls (binfo, do_self, t) ...@@ -2321,8 +2320,7 @@ finish_vtbls (binfo, do_self, t)
int is_not_base_vtable int is_not_base_vtable
= i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo)); = i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
if (TREE_VIA_VIRTUAL (base_binfo)) if (TREE_VIA_VIRTUAL (base_binfo))
base_binfo = binfo_member (BINFO_TYPE (base_binfo), base_binfo = BINFO_FOR_VBASE (BINFO_TYPE (base_binfo), t);
CLASSTYPE_VBASECLASSES (t));
finish_vtbls (base_binfo, is_not_base_vtable, t); finish_vtbls (base_binfo, is_not_base_vtable, t);
} }
} }
...@@ -2375,8 +2373,7 @@ get_class_offset_1 (parent, binfo, context, t, fndecl) ...@@ -2375,8 +2373,7 @@ get_class_offset_1 (parent, binfo, context, t, fndecl)
tree nrval; tree nrval;
if (TREE_VIA_VIRTUAL (base_binfo)) if (TREE_VIA_VIRTUAL (base_binfo))
base_binfo = binfo_member (BINFO_TYPE (base_binfo), base_binfo = BINFO_FOR_VBASE (BINFO_TYPE (base_binfo), t);
CLASSTYPE_VBASECLASSES (t));
nrval = get_class_offset_1 (parent, base_binfo, context, t, fndecl); nrval = get_class_offset_1 (parent, base_binfo, context, t, fndecl);
/* See if we have a new value */ /* See if we have a new value */
if (nrval && (nrval != error_mark_node || rval==0)) if (nrval && (nrval != error_mark_node || rval==0))
...@@ -2699,7 +2696,7 @@ modify_all_indirect_vtables (binfo, do_self, via_virtual, t, fndecl) ...@@ -2699,7 +2696,7 @@ modify_all_indirect_vtables (binfo, do_self, via_virtual, t, fndecl)
if (TREE_VIA_VIRTUAL (base_binfo)) if (TREE_VIA_VIRTUAL (base_binfo))
{ {
via_virtual = 1; via_virtual = 1;
base_binfo = binfo_member (BINFO_TYPE (base_binfo), CLASSTYPE_VBASECLASSES (t)); base_binfo = BINFO_FOR_VBASE (BINFO_TYPE (base_binfo), t);
} }
modify_all_indirect_vtables (base_binfo, is_not_base_vtable, via_virtual, t, fndecl); modify_all_indirect_vtables (base_binfo, is_not_base_vtable, via_virtual, t, fndecl);
} }
...@@ -3769,10 +3766,7 @@ build_vbase_pointer_fields (rec, empty_p) ...@@ -3769,10 +3766,7 @@ build_vbase_pointer_fields (rec, empty_p)
{ {
tree other_base_binfo = TREE_VEC_ELT (binfos, j); tree other_base_binfo = TREE_VEC_ELT (binfos, j);
if (! TREE_VIA_VIRTUAL (other_base_binfo) if (! TREE_VIA_VIRTUAL (other_base_binfo)
&& binfo_member (basetype, && BINFO_FOR_VBASE (basetype, BINFO_TYPE (other_base_binfo)))
CLASSTYPE_VBASECLASSES (BINFO_TYPE
(other_base_binfo))
))
goto got_it; goto got_it;
} }
FORMAT_VBASE_NAME (name, basetype); FORMAT_VBASE_NAME (name, basetype);
......
...@@ -1406,16 +1406,22 @@ struct lang_type ...@@ -1406,16 +1406,22 @@ struct lang_type
/* The number of virtual functions defined for this /* The number of virtual functions defined for this
_CLASSTYPE node. */ _CLASSTYPE node. */
#define CLASSTYPE_VSIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->vsize) #define CLASSTYPE_VSIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->vsize)
/* The direct and indirect virtual base classes that this type uses in
depth-first left-to-right order. */ /* A chain of BINFOs for the direct and indirect virtual base classes
that this type uses in depth-first left-to-right order. */
#define CLASSTYPE_VBASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->vbases) #define CLASSTYPE_VBASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->vbases)
/* The BINFO (if any) for the virtual baseclass T of the class C. */
#define BINFO_FOR_VBASE(T, C) \
(binfo_member (T, CLASSTYPE_VBASECLASSES (C)))
/* The virtual function pointer fields that this type contains. */ /* The virtual function pointer fields that this type contains. */
#define CLASSTYPE_VFIELDS(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfields) #define CLASSTYPE_VFIELDS(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfields)
/* Number of baseclasses defined for this type. /* Number of direct baseclasses of NODE. */
0 means no base classes. */
#define CLASSTYPE_N_BASECLASSES(NODE) \ #define CLASSTYPE_N_BASECLASSES(NODE) \
(TYPE_BINFO_BASETYPES (NODE) ? TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES(NODE)) : 0) (TYPE_BINFO_BASETYPES (NODE) ? \
TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES(NODE)) : 0)
/* Used for keeping search-specific information. Any search routine /* Used for keeping search-specific information. Any search routine
which uses this must define what exactly this slot is used for. */ which uses this must define what exactly this slot is used for. */
...@@ -3877,7 +3883,7 @@ extern void get_pure_virtuals PROTO((tree)); ...@@ -3877,7 +3883,7 @@ extern void get_pure_virtuals PROTO((tree));
extern tree init_vbase_pointers PROTO((tree, tree)); extern tree init_vbase_pointers PROTO((tree, tree));
extern void expand_indirect_vtbls_init PROTO((tree, tree, tree)); extern void expand_indirect_vtbls_init PROTO((tree, tree, tree));
extern void clear_search_slots PROTO((tree)); extern void clear_search_slots PROTO((tree));
extern tree get_vbase_types PROTO((tree)); extern void get_vbase_types PROTO((tree));
extern void maybe_suppress_debug_info PROTO((tree)); extern void maybe_suppress_debug_info PROTO((tree));
extern void note_debug_info_needed PROTO((tree)); extern void note_debug_info_needed PROTO((tree));
extern void push_class_decls PROTO((tree)); extern void push_class_decls PROTO((tree));
......
...@@ -12522,7 +12522,7 @@ xref_basetypes (code_type_node, name, ref, binfo) ...@@ -12522,7 +12522,7 @@ xref_basetypes (code_type_node, name, ref, binfo)
/* Now that we know all the base-classes, set up the list of virtual /* Now that we know all the base-classes, set up the list of virtual
bases. */ bases. */
CLASSTYPE_VBASECLASSES (ref) = get_vbase_types (ref); get_vbase_types (ref);
} }
......
...@@ -388,10 +388,7 @@ sort_base_init (t, rbase_ptr, vbase_ptr) ...@@ -388,10 +388,7 @@ sort_base_init (t, rbase_ptr, vbase_ptr)
this constructor is the top-level constructor called. */ this constructor is the top-level constructor called. */
if (TREE_VIA_VIRTUAL (binfo)) if (TREE_VIA_VIRTUAL (binfo))
{ {
tree v = CLASSTYPE_VBASECLASSES (t); tree v = BINFO_FOR_VBASE (BINFO_TYPE (binfo), t);
while (BINFO_TYPE (v) != BINFO_TYPE (binfo))
v = TREE_CHAIN (v);
vbases = tree_cons (v, TREE_VALUE (x), vbases); vbases = tree_cons (v, TREE_VALUE (x), vbases);
continue; continue;
} }
...@@ -916,7 +913,7 @@ expand_member_init (exp, name, init) ...@@ -916,7 +913,7 @@ expand_member_init (exp, name, init)
&& ! current_template_parms && ! current_template_parms
&& ! vec_binfo_member (basetype, && ! vec_binfo_member (basetype,
TYPE_BINFO_BASETYPES (type)) TYPE_BINFO_BASETYPES (type))
&& ! binfo_member (basetype, CLASSTYPE_VBASECLASSES (type))) && ! BINFO_FOR_VBASE (basetype, type))
{ {
if (IDENTIFIER_CLASS_VALUE (name)) if (IDENTIFIER_CLASS_VALUE (name))
goto try_member; goto try_member;
......
...@@ -485,8 +485,7 @@ get_base_distance (parent, binfo, protect, path_ptr) ...@@ -485,8 +485,7 @@ get_base_distance (parent, binfo, protect, path_ptr)
tree, deal with it. This happens when we are called from tree, deal with it. This happens when we are called from
expand_upcast_fixups. */ expand_upcast_fixups. */
if (rval == -1 && TREE_CODE (parent) == TREE_VEC if (rval == -1 && TREE_CODE (parent) == TREE_VEC
&& parent == binfo_member (BINFO_TYPE (parent), && parent == BINFO_FOR_VBASE (BINFO_TYPE (parent), type))
CLASSTYPE_VBASECLASSES (type)))
{ {
my_friendly_assert (BINFO_INHERITANCE_CHAIN (parent) == binfo, 980827); my_friendly_assert (BINFO_INHERITANCE_CHAIN (parent) == binfo, 980827);
new_binfo = parent; new_binfo = parent;
...@@ -1287,8 +1286,7 @@ lookup_field_queue_p (binfo, data) ...@@ -1287,8 +1286,7 @@ lookup_field_queue_p (binfo, data)
return NULL_TREE; return NULL_TREE;
if (TREE_VIA_VIRTUAL (binfo)) if (TREE_VIA_VIRTUAL (binfo))
return binfo_member (BINFO_TYPE (binfo), return BINFO_FOR_VBASE (BINFO_TYPE (binfo), lfi->type);
CLASSTYPE_VBASECLASSES (lfi->type));
else else
return binfo; return binfo;
} }
...@@ -2557,7 +2555,7 @@ virtual_context (fndecl, t, vbase) ...@@ -2557,7 +2555,7 @@ virtual_context (fndecl, t, vbase)
/* Not sure if checking path == vbase is necessary here, but just in /* Not sure if checking path == vbase is necessary here, but just in
case it is. */ case it is. */
if (TREE_VIA_VIRTUAL (path) || path == vbase) if (TREE_VIA_VIRTUAL (path) || path == vbase)
return binfo_member (BINFO_TYPE (path), CLASSTYPE_VBASECLASSES (t)); return BINFO_FOR_VBASE (BINFO_TYPE (path), t);
path = BINFO_INHERITANCE_CHAIN (path); path = BINFO_INHERITANCE_CHAIN (path);
} }
} }
...@@ -2886,7 +2884,7 @@ dfs_get_vbase_types (binfo, data) ...@@ -2886,7 +2884,7 @@ dfs_get_vbase_types (binfo, data)
depth-first search order. The list is freshly allocated, so depth-first search order. The list is freshly allocated, so
no modification is made to the current binfo hierarchy. */ no modification is made to the current binfo hierarchy. */
tree void
get_vbase_types (type) get_vbase_types (type)
tree type; tree type;
{ {
...@@ -2906,7 +2904,7 @@ get_vbase_types (type) ...@@ -2906,7 +2904,7 @@ get_vbase_types (type)
for (vbases = vbase_types; vbases; vbases = TREE_CHAIN (vbases)) for (vbases = vbase_types; vbases; vbases = TREE_CHAIN (vbases))
CLEAR_BINFO_VBASE_MARKED (vbases); CLEAR_BINFO_VBASE_MARKED (vbases);
return vbase_types; CLASSTYPE_VBASECLASSES (type) = vbase_types;
} }
/* Debug info for C++ classes can get very large; try to avoid /* Debug info for C++ classes can get very large; try to avoid
......
...@@ -6045,8 +6045,7 @@ get_delta_difference (from, to, force) ...@@ -6045,8 +6045,7 @@ get_delta_difference (from, to, force)
return delta; return delta;
if (binfo_from_vbase (binfo)) if (binfo_from_vbase (binfo))
{ {
binfo = binfo_member (BINFO_TYPE (binfo), binfo = BINFO_FOR_VBASE (BINFO_TYPE (binfo), from);
CLASSTYPE_VBASECLASSES (from));
cp_warning ("pointer to member cast to virtual base `%T'", cp_warning ("pointer to member cast to virtual base `%T'",
BINFO_TYPE (binfo)); BINFO_TYPE (binfo));
warning (" will only work if you are very careful"); warning (" will only work if you are very careful");
......
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