From 233811559ad3b89e994cd0f5c6f09ecc1d9bb9be Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 31 Dec 1999 20:26:07 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 22 ++++++++++++++++++++++ gcc/cp/class.c | 24 +++++++++--------------- gcc/cp/cp-tree.h | 18 ++++++++++++------ gcc/cp/decl.c | 2 +- gcc/cp/init.c | 7 ++----- gcc/cp/search.c | 12 +++++------- gcc/cp/typeck.c | 3 +-- 7 files changed, 52 insertions(+), 36 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6c961f14c03..cd44cf9d764 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,25 @@ +1999-12-31 Mark Mitchell + + * 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 * class.c (fixup_inline_methods): Clear CLASSTYPE_INLINE_FRIENDS. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 4a75af99894..10dff6e657a 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -331,8 +331,8 @@ build_vbase_path (code, type, expr, path, nonnull) { 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 @@ -884,8 +884,7 @@ prepare_fresh_vtable (binfo, for_type) 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 @@ -911,8 +910,8 @@ prepare_fresh_vtable (binfo, for_type) 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); } @@ -2321,8 +2320,7 @@ finish_vtbls (binfo, do_self, t) 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); } } @@ -2375,8 +2373,7 @@ get_class_offset_1 (parent, binfo, context, t, fndecl) 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)) @@ -2699,7 +2696,7 @@ modify_all_indirect_vtables (binfo, do_self, via_virtual, t, fndecl) 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); } @@ -3769,10 +3766,7 @@ build_vbase_pointer_fields (rec, empty_p) { 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); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index d5be18cb074..3b3596f98ce 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1406,16 +1406,22 @@ struct lang_type /* 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. */ @@ -3877,7 +3883,7 @@ extern void get_pure_virtuals PROTO((tree)); 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)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e1b27ce82c8..f0b7f8acab2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 bases. */ - CLASSTYPE_VBASECLASSES (ref) = get_vbase_types (ref); + get_vbase_types (ref); } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index e841feeacb9..893ee545688 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -388,10 +388,7 @@ sort_base_init (t, rbase_ptr, vbase_ptr) 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; } @@ -916,7 +913,7 @@ expand_member_init (exp, name, init) && ! 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; diff --git a/gcc/cp/search.c b/gcc/cp/search.c index ba414de4e0b..798099a4d9e 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -485,8 +485,7 @@ get_base_distance (parent, binfo, protect, path_ptr) 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; @@ -1287,8 +1286,7 @@ lookup_field_queue_p (binfo, data) 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; } @@ -2557,7 +2555,7 @@ virtual_context (fndecl, t, vbase) /* 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); } } @@ -2886,7 +2884,7 @@ dfs_get_vbase_types (binfo, data) 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; { @@ -2906,7 +2904,7 @@ get_vbase_types (type) for (vbases = vbase_types; vbases; vbases = TREE_CHAIN (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 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 9d5bfa781db..808d702141c 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6045,8 +6045,7 @@ get_delta_difference (from, to, force) 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");