From 0871761b07caa5c85920d72b0bf7b282b1864a1b Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 28 Jul 2004 08:50:27 +0000 Subject: [PATCH] cp-tree.h (struct tree_pair_s): New. * cp-tree.h (struct tree_pair_s): New. (typedef tree_pair_p): New. (DEF_VEC_O(tree_pair_s)): New. (struct lang_type_class): Make vcall_indices a VEC(tree_pair_s). (CLASSTYPE_VCALL_INDICES): Update documentation. * class.c (get_vcall_index): Adjust. (add_vcall_offset): Adjust. From-SVN: r85256 --- gcc/cp/ChangeLog | 10 ++++++++++ gcc/cp/class.c | 28 +++++++++++++++++----------- gcc/cp/cp-tree.h | 25 +++++++++++++++++-------- 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2bc1ce08d7d..f71e01d7652 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2004-07-28 Nathan Sidwell + + * cp-tree.h (struct tree_pair_s): New. + (typedef tree_pair_p): New. + (DEF_VEC_O(tree_pair_s)): New. + (struct lang_type_class): Make vcall_indices a VEC(tree_pair_s). + (CLASSTYPE_VCALL_INDICES): Update documentation. + * class.c (get_vcall_index): Adjust. + (add_vcall_offset): Adjust. + 2004-07-27 Kelley Cook * pt.c, typeck.c: Remove spurious carriage returns. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index f30d519fe8f..8da2e586548 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1955,17 +1955,19 @@ find_final_overrider (tree derived, tree binfo, tree fn) static tree get_vcall_index (tree fn, tree type) { - tree v; + VEC (tree_pair_s) *indices = CLASSTYPE_VCALL_INDICES (type); + tree_pair_p p; + unsigned ix; - for (v = CLASSTYPE_VCALL_INDICES (type); v; v = TREE_CHAIN (v)) - if ((DECL_DESTRUCTOR_P (fn) && DECL_DESTRUCTOR_P (TREE_PURPOSE (v))) - || same_signature_p (fn, TREE_PURPOSE (v))) - break; + for (ix = 0; VEC_iterate (tree_pair_s, indices, ix, p); ix++) + if ((DECL_DESTRUCTOR_P (fn) && DECL_DESTRUCTOR_P (p->purpose)) + || same_signature_p (fn, p->purpose)) + return p->value; /* There should always be an appropriate index. */ - my_friendly_assert (v, 20021103); + abort (); - return TREE_VALUE (v); + return NULL_TREE; } /* Update an entry in the vtable for BINFO, which is in the hierarchy @@ -7682,10 +7684,14 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) the vtable for the most derived class, remember the vcall offset. */ if (vid->binfo == TYPE_BINFO (vid->derived)) - CLASSTYPE_VCALL_INDICES (vid->derived) - = tree_cons (orig_fn, vid->index, - CLASSTYPE_VCALL_INDICES (vid->derived)); - + { + tree_pair_p elt = VEC_safe_push (tree_pair_s, + CLASSTYPE_VCALL_INDICES (vid->derived), + NULL); + elt->purpose = orig_fn; + elt->value = vid->index; + } + /* The next vcall offset will be found at a more negative offset. */ vid->index = size_binop (MINUS_EXPR, vid->index, diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index e7eed5e4437..c69320fadbc 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -933,9 +933,18 @@ enum languages { lang_c, lang_cplusplus, lang_java }; != NULL_TREE) /* Gives the visibility specification for a class type. */ -#define CLASSTYPE_VISIBILITY(TYPE) DECL_VISIBILITY (TYPE_NAME (TYPE)) -#define CLASSTYPE_VISIBILITY_SPECIFIED(TYPE) DECL_VISIBILITY_SPECIFIED (TYPE_NAME (TYPE)) +#define CLASSTYPE_VISIBILITY(TYPE) \ + DECL_VISIBILITY (TYPE_NAME (TYPE)) +#define CLASSTYPE_VISIBILITY_SPECIFIED(TYPE) \ + DECL_VISIBILITY_SPECIFIED (TYPE_NAME (TYPE)) +typedef struct tree_pair_s GTY (()) +{ + tree purpose; + tree value; +} tree_pair_s; +typedef tree_pair_s *tree_pair_p; +DEF_VEC_O (tree_pair_s); /* This is a few header flags for 'struct lang_type'. Actually, all but the first are used only for lang_type_class; they @@ -1020,7 +1029,7 @@ struct lang_type_class GTY(()) unsigned dummy : 8; tree primary_base; - tree vcall_indices; + VEC (tree_pair_s) *vcall_indices; tree vtables; tree typeinfo_var; VEC (tree) *vbases; @@ -1432,11 +1441,11 @@ struct lang_type GTY(()) /* Used by various search routines. */ #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE) -/* A TREE_LIST of the vcall indices associated with the class NODE. - The TREE_PURPOSE of each node is a FUNCTION_DECL for a virtual - function. The TREE_VALUE is the index into the virtual table where - the vcall offset for that function is stored, when NODE is a - virtual base. */ +/* A VEC(tree_pair_s) of the vcall indices associated with the class + NODE. The PURPOSE of each element is a FUNCTION_DECL for a virtual + function. The VALUE is the index into the virtual table where the + vcall offset for that function is stored, when NODE is a virtual + base. */ #define CLASSTYPE_VCALL_INDICES(NODE) \ (LANG_TYPE_CLASS_CHECK (NODE)->vcall_indices) -- 2.30.2