cp-tree.h (SAME_BINFO_TYPE_P): New.
* cp-tree.h (SAME_BINFO_TYPE_P): New. * class.c (build_base_path): Use SAME_BINFO_TYPE_P to compare binfo types. (convert_to_base_statically, determine_primary_bases, update_vtable_entry_for_fn, dfs_modify_vtables, build_vtt_inits, dfs_build_secondary_vptr_vtt_inits, build_ctor_vtbl_group, accumulate_vtbl_inits, dfs_accumulate_vtbl_inits, build_vtbl_initializer, add_vcall_offset_vtbl_entries_1): Likewise. * init.c (expand_member_init): Likewise. * search.c (lookup_base_r, dynamic_cast_base_recurse, binfo_via_virtual, copied_binfo, binfo_for_vbase, original_binfo): Likewise. * tree.c (copy_binfo): Likewise. From-SVN: r88880
This commit is contained in:
parent
19b63d8ecd
commit
539ed333f6
|
@ -1,3 +1,19 @@
|
|||
2004-10-11 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* cp-tree.h (SAME_BINFO_TYPE_P): New.
|
||||
* class.c (build_base_path): Use SAME_BINFO_TYPE_P to compare
|
||||
binfo types.
|
||||
(convert_to_base_statically, determine_primary_bases,
|
||||
update_vtable_entry_for_fn, dfs_modify_vtables, build_vtt_inits,
|
||||
dfs_build_secondary_vptr_vtt_inits, build_ctor_vtbl_group,
|
||||
accumulate_vtbl_inits, dfs_accumulate_vtbl_inits,
|
||||
build_vtbl_initializer, add_vcall_offset_vtbl_entries_1): Likewise.
|
||||
* init.c (expand_member_init): Likewise.
|
||||
* search.c (lookup_base_r, dynamic_cast_base_recurse,
|
||||
binfo_via_virtual, copied_binfo, binfo_for_vbase,
|
||||
original_binfo): Likewise.
|
||||
* tree.c (copy_binfo): Likewise.
|
||||
|
||||
2004-10-11 Kazu Hirata <kazu@cs.umass.edu>
|
||||
|
||||
* semantics.c: Fix comment typos.
|
||||
|
|
|
@ -259,11 +259,10 @@ build_base_path (enum tree_code code,
|
|||
if (want_pointer)
|
||||
probe = TYPE_MAIN_VARIANT (TREE_TYPE (probe));
|
||||
|
||||
gcc_assert (code == MINUS_EXPR
|
||||
? same_type_p (BINFO_TYPE (binfo), probe)
|
||||
: code == PLUS_EXPR
|
||||
? same_type_p (BINFO_TYPE (d_binfo), probe)
|
||||
: false);
|
||||
gcc_assert ((code == MINUS_EXPR
|
||||
&& SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), probe))
|
||||
|| (code == PLUS_EXPR
|
||||
&& SAME_BINFO_TYPE_P (BINFO_TYPE (d_binfo), probe)));
|
||||
|
||||
if (binfo == d_binfo)
|
||||
/* Nothing to do. */
|
||||
|
@ -445,8 +444,8 @@ convert_to_base (tree object, tree type, bool check_access)
|
|||
return build_base_path (PLUS_EXPR, object, binfo, /*nonnull=*/1);
|
||||
}
|
||||
|
||||
/* EXPR is an expression with class type. BASE is a base class (a
|
||||
BINFO) of that class type. Returns EXPR, converted to the BASE
|
||||
/* EXPR is an expression with unqualified class type. BASE is a base
|
||||
binfo of that class type. Returns EXPR, converted to the BASE
|
||||
type. This function assumes that EXPR is the most derived class;
|
||||
therefore virtual bases can be found at their static offsets. */
|
||||
|
||||
|
@ -456,7 +455,7 @@ convert_to_base_statically (tree expr, tree base)
|
|||
tree expr_type;
|
||||
|
||||
expr_type = TREE_TYPE (expr);
|
||||
if (!same_type_p (expr_type, BINFO_TYPE (base)))
|
||||
if (!SAME_BINFO_TYPE_P (BINFO_TYPE (base), expr_type))
|
||||
{
|
||||
tree pointer_type;
|
||||
|
||||
|
@ -1276,7 +1275,8 @@ determine_primary_bases (tree t)
|
|||
tree parent_primary = CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (parent));
|
||||
|
||||
if (parent_primary
|
||||
&& BINFO_TYPE (base_binfo) == BINFO_TYPE (parent_primary))
|
||||
&& SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo),
|
||||
BINFO_TYPE (parent_primary)))
|
||||
/* We are the primary binfo. */
|
||||
BINFO_PRIMARY_P (base_binfo) = 1;
|
||||
}
|
||||
|
@ -2062,8 +2062,8 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals,
|
|||
{
|
||||
/* If we find the final overrider, then we can stop
|
||||
walking. */
|
||||
if (same_type_p (BINFO_TYPE (b),
|
||||
BINFO_TYPE (TREE_VALUE (overrider))))
|
||||
if (SAME_BINFO_TYPE_P (BINFO_TYPE (b),
|
||||
BINFO_TYPE (TREE_VALUE (overrider))))
|
||||
break;
|
||||
|
||||
/* If we find a virtual base, and we haven't yet found the
|
||||
|
@ -2153,7 +2153,8 @@ dfs_modify_vtables (tree binfo, void* data)
|
|||
/* Similarly, a base without a vtable needs no modification. */
|
||||
&& TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo))
|
||||
/* Don't do the primary vtable, if it's new. */
|
||||
&& (BINFO_TYPE (binfo) != t || CLASSTYPE_HAS_PRIMARY_BASE_P (t)))
|
||||
&& (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t)
|
||||
|| CLASSTYPE_HAS_PRIMARY_BASE_P (t)))
|
||||
{
|
||||
tree virtuals;
|
||||
tree old_virtuals;
|
||||
|
@ -6697,7 +6698,7 @@ build_vtt_inits (tree binfo, tree t, tree *inits, tree *index)
|
|||
tree init;
|
||||
tree secondary_vptrs;
|
||||
secondary_vptr_vtt_init_data data;
|
||||
int top_level_p = same_type_p (TREE_TYPE (binfo), t);
|
||||
int top_level_p = SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t);
|
||||
|
||||
/* We only need VTTs for subobjects with virtual bases. */
|
||||
if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)))
|
||||
|
@ -6783,7 +6784,7 @@ dfs_build_secondary_vptr_vtt_inits (tree binfo, void *data_)
|
|||
|
||||
/* We're only interested in proper subobjects of the type being
|
||||
constructed. */
|
||||
if (same_type_p (BINFO_TYPE (binfo), data->type_being_constructed))
|
||||
if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), data->type_being_constructed))
|
||||
return NULL_TREE;
|
||||
|
||||
/* We're only interested in bases with virtual bases or reachable
|
||||
|
@ -6869,7 +6870,7 @@ build_ctor_vtbl_group (tree binfo, tree t)
|
|||
if (IDENTIFIER_GLOBAL_VALUE (id))
|
||||
return;
|
||||
|
||||
gcc_assert (!same_type_p (BINFO_TYPE (binfo), t));
|
||||
gcc_assert (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t));
|
||||
/* Build a version of VTBL (with the wrong type) for use in
|
||||
constructing the addresses of secondary vtables in the
|
||||
construction vtable group. */
|
||||
|
@ -6925,9 +6926,9 @@ accumulate_vtbl_inits (tree binfo,
|
|||
{
|
||||
int i;
|
||||
tree base_binfo;
|
||||
int ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t);
|
||||
int ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t);
|
||||
|
||||
gcc_assert (same_type_p (BINFO_TYPE (binfo), BINFO_TYPE (orig_binfo)));
|
||||
gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), BINFO_TYPE (orig_binfo)));
|
||||
|
||||
/* If it doesn't have a vptr, we don't do anything. */
|
||||
if (!TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo)))
|
||||
|
@ -6975,7 +6976,7 @@ dfs_accumulate_vtbl_inits (tree binfo,
|
|||
{
|
||||
tree inits = NULL_TREE;
|
||||
tree vtbl = NULL_TREE;
|
||||
int ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t);
|
||||
int ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t);
|
||||
|
||||
if (ctor_vtbl_p
|
||||
&& BINFO_VIRTUAL_P (orig_binfo) && BINFO_PRIMARY_P (orig_binfo))
|
||||
|
@ -7109,8 +7110,8 @@ build_vtbl_initializer (tree binfo,
|
|||
vid.derived = t;
|
||||
vid.rtti_binfo = rtti_binfo;
|
||||
vid.last_init = &vid.inits;
|
||||
vid.primary_vtbl_p = (binfo == TYPE_BINFO (t));
|
||||
vid.ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t);
|
||||
vid.primary_vtbl_p = SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t);
|
||||
vid.ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t);
|
||||
vid.generate_vcall_entries = true;
|
||||
/* The first vbase or vcall offset is at index -3 in the vtable. */
|
||||
vid.index = ssize_int(-3 * TARGET_VTABLE_DATA_ENTRY_DISTANCE);
|
||||
|
@ -7523,7 +7524,7 @@ add_vcall_offset_vtbl_entries_1 (tree binfo, vtbl_init_data* vid)
|
|||
/* When processing BINFO, we only want to generate vcall slots for
|
||||
function slots introduced in BINFO. So don't try to generate
|
||||
one if the function isn't even defined in BINFO. */
|
||||
if (!same_type_p (DECL_CONTEXT (orig_fn), BINFO_TYPE (binfo)))
|
||||
if (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), DECL_CONTEXT (orig_fn)))
|
||||
continue;
|
||||
|
||||
add_vcall_offset (orig_fn, binfo, vid);
|
||||
|
|
|
@ -1370,6 +1370,14 @@ struct lang_type GTY(())
|
|||
have this flag set. */
|
||||
#define BINFO_NEW_VTABLE_MARKED(B) (BINFO_FLAG_2 (B))
|
||||
|
||||
/* Compare a BINFO_TYPE with another type for equality. For a binfo,
|
||||
this is functionally equivalent to using same_type_p, but
|
||||
measurably faster. At least one of the arguments must be a
|
||||
BINFO_TYPE. The other can be a BINFO_TYPE or a regular type. If
|
||||
BINFO_TYPE(T) ever stops being the main variant of the class the
|
||||
binfo is for, this macro must change. */
|
||||
#define SAME_BINFO_TYPE_P(A, B) ((A) == (B))
|
||||
|
||||
/* Any subobject that needs a new vtable must have a vptr and must not
|
||||
be a non-virtual primary base (since it would then use the vtable from a
|
||||
derived class and never become non-primary.) */
|
||||
|
|
|
@ -979,7 +979,7 @@ expand_member_init (tree name)
|
|||
|
||||
/* Look for a direct base. */
|
||||
for (i = 0; BINFO_BASE_ITERATE (class_binfo, i, direct_binfo); ++i)
|
||||
if (same_type_p (basetype, BINFO_TYPE (direct_binfo)))
|
||||
if (SAME_BINFO_TYPE_P (BINFO_TYPE (direct_binfo), basetype))
|
||||
break;
|
||||
|
||||
/* Look for a virtual base -- unless the direct base is itself
|
||||
|
|
|
@ -90,7 +90,7 @@ lookup_base_r (tree binfo, tree base, base_access access,
|
|||
tree base_binfo;
|
||||
base_kind found = bk_not_base;
|
||||
|
||||
if (same_type_p (BINFO_TYPE (binfo), base))
|
||||
if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), base))
|
||||
{
|
||||
/* We have found a base. Check against what we have found
|
||||
already. */
|
||||
|
@ -279,7 +279,7 @@ dynamic_cast_base_recurse (tree subtype, tree binfo, bool is_via_virtual,
|
|||
int i;
|
||||
int worst = -2;
|
||||
|
||||
if (BINFO_TYPE (binfo) == subtype)
|
||||
if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), subtype))
|
||||
{
|
||||
if (is_via_virtual)
|
||||
return -1;
|
||||
|
@ -2346,7 +2346,7 @@ binfo_from_vbase (tree binfo)
|
|||
tree
|
||||
binfo_via_virtual (tree binfo, tree limit)
|
||||
{
|
||||
for (; binfo && (!limit || !same_type_p (BINFO_TYPE (binfo), limit));
|
||||
for (; binfo && !SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), limit);
|
||||
binfo = BINFO_INHERITANCE_CHAIN (binfo))
|
||||
{
|
||||
if (BINFO_VIRTUAL_P (binfo))
|
||||
|
@ -2382,7 +2382,7 @@ copied_binfo (tree binfo, tree here)
|
|||
|
||||
cbinfo = copied_binfo (BINFO_INHERITANCE_CHAIN (binfo), here);
|
||||
for (ix = 0; BINFO_BASE_ITERATE (cbinfo, ix, base_binfo); ix++)
|
||||
if (BINFO_TYPE (base_binfo) == BINFO_TYPE (binfo))
|
||||
if (SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo), BINFO_TYPE (binfo)))
|
||||
{
|
||||
result = base_binfo;
|
||||
break;
|
||||
|
@ -2390,7 +2390,7 @@ copied_binfo (tree binfo, tree here)
|
|||
}
|
||||
else
|
||||
{
|
||||
gcc_assert (BINFO_TYPE (here) == BINFO_TYPE (binfo));
|
||||
gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (here), BINFO_TYPE (binfo)));
|
||||
result = here;
|
||||
}
|
||||
|
||||
|
@ -2407,7 +2407,7 @@ binfo_for_vbase (tree base, tree t)
|
|||
|
||||
for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0;
|
||||
VEC_iterate (tree, vbases, ix, binfo); ix++)
|
||||
if (BINFO_TYPE (binfo) == base)
|
||||
if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), base))
|
||||
return binfo;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2422,7 +2422,7 @@ original_binfo (tree binfo, tree here)
|
|||
{
|
||||
tree result = NULL;
|
||||
|
||||
if (BINFO_TYPE (binfo) == BINFO_TYPE (here))
|
||||
if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), BINFO_TYPE (here)))
|
||||
result = here;
|
||||
else if (BINFO_VIRTUAL_P (binfo))
|
||||
result = (CLASSTYPE_VBASECLASSES (BINFO_TYPE (here))
|
||||
|
@ -2439,7 +2439,8 @@ original_binfo (tree binfo, tree here)
|
|||
tree base_binfo;
|
||||
|
||||
for (ix = 0; (base_binfo = BINFO_BASE_BINFO (base_binfos, ix)); ix++)
|
||||
if (BINFO_TYPE (base_binfo) == BINFO_TYPE (binfo))
|
||||
if (SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo),
|
||||
BINFO_TYPE (binfo)))
|
||||
{
|
||||
result = base_binfo;
|
||||
break;
|
||||
|
|
|
@ -611,7 +611,7 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
|
|||
tree base_binfo;
|
||||
|
||||
gcc_assert (!BINFO_DEPENDENT_BASE_P (binfo));
|
||||
gcc_assert (type == BINFO_TYPE (binfo));
|
||||
gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), type));
|
||||
|
||||
BINFO_OFFSET (new_binfo) = BINFO_OFFSET (binfo);
|
||||
BINFO_VIRTUALS (new_binfo) = BINFO_VIRTUALS (binfo);
|
||||
|
|
Loading…
Reference in New Issue