Commit 2401ffc3 by Nathan Sidwell Committed by Nathan Sidwell

Remove special CDtor METHOD_VEC slots.

	* cp-tree.h (CLASSTYPE_CONSTRUCTOR_SLOT,
	CLASSTYPE_DESTRUCTOR_SLOT): Delete.
	(CLASSTYPE_CONSTRUCTORS): Use lookup_fnfields_slot_nolazy.
	(CLASSTYPE_DESTRUCTOR): Likewise.
	* class (add_method): Don't use special cdtor slots.
	* search.c (lookup_fnfields_idx_nolazy): Likewise.
	(look_for_overrides_here): Use lookup_fnfields_slot.
	* semantics (classtype_has_nothrow_assign_or_copy_p): Likewise.

From-SVN: r250437
parent 0ab71760
2017-07-21 Nathan Sidwell <nathan@acm.org>
Remove special CDtor METHOD_VEC slots.
* cp-tree.h (CLASSTYPE_CONSTRUCTOR_SLOT,
CLASSTYPE_DESTRUCTOR_SLOT): Delete.
(CLASSTYPE_CONSTRUCTORS): Use lookup_fnfields_slot_nolazy.
(CLASSTYPE_DESTRUCTOR): Likewise.
* class (add_method): Don't use special cdtor slots.
* search.c (lookup_fnfields_idx_nolazy): Likewise.
(look_for_overrides_here): Use lookup_fnfields_slot.
* semantics (classtype_has_nothrow_assign_or_copy_p): Likewise.
* call.c (add_candidates): Move decls to initialization. Don't
use !!.
......
......@@ -1039,22 +1039,12 @@ add_method (tree type, tree method, bool via_using)
we're going to end up with an assignment operator at some
point as well. */
vec_alloc (method_vec, 8);
/* Create slots for constructors and destructors. */
method_vec->quick_push (NULL_TREE);
method_vec->quick_push (NULL_TREE);
CLASSTYPE_METHOD_VEC (type) = method_vec;
}
/* Maintain TYPE_HAS_USER_CONSTRUCTOR, etc. */
grok_special_member_properties (method);
/* Constructors and destructors go in special slots. */
if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (method))
slot = CLASSTYPE_CONSTRUCTOR_SLOT;
else if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (method))
slot = CLASSTYPE_DESTRUCTOR_SLOT;
else
{
tree m;
insert_p = true;
......@@ -1083,7 +1073,6 @@ add_method (tree type, tree method, bool via_using)
&& DECL_NAME (m) > DECL_NAME (method))
break;
}
}
current_fns = insert_p ? NULL_TREE : (*method_vec)[slot];
/* Check to see if we've already got this method. */
......@@ -1256,7 +1245,7 @@ add_method (tree type, tree method, bool via_using)
if (conv_p)
TYPE_HAS_CONVERSION (type) = 1;
else if (slot >= CLASSTYPE_FIRST_CONVERSION_SLOT && !complete_p)
else if (!complete_p && !IDENTIFIER_CDTOR_P (DECL_NAME (method)))
push_class_level_binding (DECL_NAME (method), current_fns);
if (insert_p)
......
......@@ -2148,29 +2148,21 @@ struct GTY(()) lang_type {
and the RECORD_TYPE for the class template otherwise. */
#define CLASSTYPE_DECL_LIST(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->decl_list)
/* The slot in the CLASSTYPE_METHOD_VEC where constructors go. */
#define CLASSTYPE_CONSTRUCTOR_SLOT 0
/* The slot in the CLASSTYPE_METHOD_VEC where destructors go. */
#define CLASSTYPE_DESTRUCTOR_SLOT 1
/* The first slot in the CLASSTYPE_METHOD_VEC where conversion
operators can appear. */
#define CLASSTYPE_FIRST_CONVERSION_SLOT 2
#define CLASSTYPE_FIRST_CONVERSION_SLOT 0
/* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
are the constructors that take an in-charge parameter. */
#define CLASSTYPE_CONSTRUCTORS(NODE) \
((*CLASSTYPE_METHOD_VEC (NODE))[CLASSTYPE_CONSTRUCTOR_SLOT])
(lookup_fnfields_slot_nolazy (NODE, ctor_identifier))
/* A FUNCTION_DECL for the destructor for NODE. This is the
destructors that take an in-charge parameter. If
CLASSTYPE_LAZY_DESTRUCTOR is true, then this entry will be NULL
until the destructor is created with lazily_declare_fn. */
#define CLASSTYPE_DESTRUCTOR(NODE) \
(CLASSTYPE_METHOD_VEC (NODE) \
? (*CLASSTYPE_METHOD_VEC (NODE))[CLASSTYPE_DESTRUCTOR_SLOT] \
: NULL_TREE)
(lookup_fnfields_slot_nolazy (NODE, dtor_identifier))
/* A dictionary of the nested user-defined-types (class-types, or enums)
found within this class. This table includes nested member class
......
......@@ -1590,18 +1590,6 @@ lookup_fnfields_idx_nolazy (tree type, tree name)
if (GATHER_STATISTICS)
n_calls_lookup_fnfields_1++;
/* Constructors are first... */
if (name == ctor_identifier)
{
fn = CLASSTYPE_CONSTRUCTORS (type);
return fn ? CLASSTYPE_CONSTRUCTOR_SLOT : -1;
}
/* and destructors are second. */
if (name == dtor_identifier)
{
fn = CLASSTYPE_DESTRUCTOR (type);
return fn ? CLASSTYPE_DESTRUCTOR_SLOT : -1;
}
if (IDENTIFIER_CONV_OP_P (name))
return lookup_conversion_operator (type, TREE_TYPE (name));
......@@ -2428,20 +2416,9 @@ look_for_overrides (tree type, tree fndecl)
tree
look_for_overrides_here (tree type, tree fndecl)
{
int ix;
/* If there are no methods in TYPE (meaning that only implicitly
declared methods will ever be provided for TYPE), then there are
no virtual functions. */
if (!CLASSTYPE_METHOD_VEC (type))
return NULL_TREE;
tree ovl = lookup_fnfields_slot (type, DECL_NAME (fndecl));
if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fndecl))
ix = CLASSTYPE_DESTRUCTOR_SLOT;
else
ix = lookup_fnfields_1 (type, DECL_NAME (fndecl));
if (ix >= 0)
for (ovl_iterator iter ((*CLASSTYPE_METHOD_VEC (type))[ix]); iter; ++iter)
for (ovl_iterator iter (ovl); iter; ++iter)
{
tree fn = *iter;
......
......@@ -9083,15 +9083,7 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p)
if (assign_p)
fns = lookup_fnfields_slot (type, cp_assignment_operator_id (NOP_EXPR));
else if (TYPE_HAS_COPY_CTOR (type))
{
/* If construction of the copy constructor was postponed, create
it now. */
if (CLASSTYPE_LAZY_COPY_CTOR (type))
lazily_declare_fn (sfk_copy_constructor, type);
if (CLASSTYPE_LAZY_MOVE_CTOR (type))
lazily_declare_fn (sfk_move_constructor, type);
fns = CLASSTYPE_CONSTRUCTORS (type);
}
fns = lookup_fnfields_slot (type, ctor_identifier);
bool saw_copy = false;
for (ovl_iterator iter (fns); iter; ++iter)
......
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