(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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31150
138bc75d-0d04-0410-961f-
82ee72b054a4
+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>
* class.c (fixup_inline_methods): Clear CLASSTYPE_INLINE_FRIENDS.
{
if (last_virtual)
{
- offset = BINFO_OFFSET (binfo_member (last_virtual,
- CLASSTYPE_VBASECLASSES (basetype)));
+ offset = BINFO_OFFSET (BINFO_FOR_VBASE (last_virtual,
+ basetype));
offset = size_binop (PLUS_EXPR, offset, BINFO_OFFSET (last));
}
else
if (TREE_VIA_VIRTUAL (binfo))
{
- tree binfo1 = binfo_member (BINFO_TYPE (binfo),
- CLASSTYPE_VBASECLASSES (for_type));
+ tree binfo1 = BINFO_FOR_VBASE (BINFO_TYPE (binfo), for_type);
/* XXX - This should never happen, if it does, the caller should
ensure that the binfo is from for_type's binfos, not from any
import_export_vtable (new_decl, for_type, 0);
if (TREE_VIA_VIRTUAL (binfo))
- my_friendly_assert (binfo == binfo_member (BINFO_TYPE (binfo),
- CLASSTYPE_VBASECLASSES (current_class_type)),
+ my_friendly_assert (binfo == BINFO_FOR_VBASE (BINFO_TYPE (binfo),
+ current_class_type),
170);
SET_BINFO_NEW_VTABLE_MARKED (binfo);
}
int is_not_base_vtable
= i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
if (TREE_VIA_VIRTUAL (base_binfo))
- base_binfo = binfo_member (BINFO_TYPE (base_binfo),
- CLASSTYPE_VBASECLASSES (t));
+ base_binfo = BINFO_FOR_VBASE (BINFO_TYPE (base_binfo), t);
finish_vtbls (base_binfo, is_not_base_vtable, t);
}
}
tree nrval;
if (TREE_VIA_VIRTUAL (base_binfo))
- base_binfo = binfo_member (BINFO_TYPE (base_binfo),
- CLASSTYPE_VBASECLASSES (t));
+ base_binfo = BINFO_FOR_VBASE (BINFO_TYPE (base_binfo), t);
nrval = get_class_offset_1 (parent, base_binfo, context, t, fndecl);
/* See if we have a new value */
if (nrval && (nrval != error_mark_node || rval==0))
if (TREE_VIA_VIRTUAL (base_binfo))
{
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);
}
{
tree other_base_binfo = TREE_VEC_ELT (binfos, j);
if (! TREE_VIA_VIRTUAL (other_base_binfo)
- && binfo_member (basetype,
- CLASSTYPE_VBASECLASSES (BINFO_TYPE
- (other_base_binfo))
- ))
+ && BINFO_FOR_VBASE (basetype, BINFO_TYPE (other_base_binfo)))
goto got_it;
}
FORMAT_VBASE_NAME (name, basetype);
/* The number of virtual functions defined for this
_CLASSTYPE node. */
#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)
+
+/* 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. */
#define CLASSTYPE_VFIELDS(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfields)
-/* Number of baseclasses defined for this type.
- 0 means no base classes. */
+/* Number of direct baseclasses of 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
which uses this must define what exactly this slot is used for. */
extern tree init_vbase_pointers PROTO((tree, tree));
extern void expand_indirect_vtbls_init PROTO((tree, tree, 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 note_debug_info_needed PROTO((tree));
extern void push_class_decls PROTO((tree));
/* Now that we know all the base-classes, set up the list of virtual
bases. */
- CLASSTYPE_VBASECLASSES (ref) = get_vbase_types (ref);
+ get_vbase_types (ref);
}
\f
this constructor is the top-level constructor called. */
if (TREE_VIA_VIRTUAL (binfo))
{
- tree v = CLASSTYPE_VBASECLASSES (t);
- while (BINFO_TYPE (v) != BINFO_TYPE (binfo))
- v = TREE_CHAIN (v);
-
+ tree v = BINFO_FOR_VBASE (BINFO_TYPE (binfo), t);
vbases = tree_cons (v, TREE_VALUE (x), vbases);
continue;
}
&& ! current_template_parms
&& ! vec_binfo_member (basetype,
TYPE_BINFO_BASETYPES (type))
- && ! binfo_member (basetype, CLASSTYPE_VBASECLASSES (type)))
+ && ! BINFO_FOR_VBASE (basetype, type))
{
if (IDENTIFIER_CLASS_VALUE (name))
goto try_member;
tree, deal with it. This happens when we are called from
expand_upcast_fixups. */
if (rval == -1 && TREE_CODE (parent) == TREE_VEC
- && parent == binfo_member (BINFO_TYPE (parent),
- CLASSTYPE_VBASECLASSES (type)))
+ && parent == BINFO_FOR_VBASE (BINFO_TYPE (parent), type))
{
my_friendly_assert (BINFO_INHERITANCE_CHAIN (parent) == binfo, 980827);
new_binfo = parent;
return NULL_TREE;
if (TREE_VIA_VIRTUAL (binfo))
- return binfo_member (BINFO_TYPE (binfo),
- CLASSTYPE_VBASECLASSES (lfi->type));
+ return BINFO_FOR_VBASE (BINFO_TYPE (binfo), lfi->type);
else
return binfo;
}
/* Not sure if checking path == vbase is necessary here, but just in
case it is. */
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);
}
}
depth-first search order. The list is freshly allocated, so
no modification is made to the current binfo hierarchy. */
-tree
+void
get_vbase_types (type)
tree type;
{
for (vbases = vbase_types; vbases; vbases = TREE_CHAIN (vbases))
CLEAR_BINFO_VBASE_MARKED (vbases);
- return vbase_types;
+ CLASSTYPE_VBASECLASSES (type) = vbase_types;
}
\f
/* Debug info for C++ classes can get very large; try to avoid
return delta;
if (binfo_from_vbase (binfo))
{
- binfo = binfo_member (BINFO_TYPE (binfo),
- CLASSTYPE_VBASECLASSES (from));
+ binfo = BINFO_FOR_VBASE (BINFO_TYPE (binfo), from);
cp_warning ("pointer to member cast to virtual base `%T'",
BINFO_TYPE (binfo));
warning (" will only work if you are very careful");