Now that all the cdtors have special names, we can detect them by looking at the
name, rather than a collection of other things.
For the DECL_[CD]TOR_P cases we're now comparing identifiers, removing a
STRIP_TEMPLATE
For the IN_CHARGE case we're replacing a conjunction of 3 checks (2 of which
contain STRIP_TEMPLATES) with looking at bitflags on the identifier.
That all seems like a win to me. Applied to trunk.
nathan
--
Nathan Sidwell
2017-07-12 Nathan Sidwell <[email protected]>
* cp-tree.h (DECL_CONSTRUCTOR_P, DECL_MAYBE_IN_CHARGE_CONSTRUCTOR,
DECL_DESTRUCTOR_P, DECL_MAYBE_IN_CHARGE_DESTRCTOR): Look at
identifier flags.
* decl.c (grokfndecl): Set DECL_CXX_CONSTRUCTOR and
DECL_CXX_DESTRUCTOR explicitly.
* decl2.c (grokclassfn): Likewise.
* friend.c (do_friend): Likewise.
* method.c (make_thunk, make_alias_for,
implicitly_declare_fn): Likewise.
Index: cp-tree.h
===================================================================
--- cp-tree.h (revision 250157)
+++ cp-tree.h (working copy)
@@ -2706,7 +2706,7 @@ struct GTY(()) lang_decl {
/* For FUNCTION_DECLs and TEMPLATE_DECLs: nonzero means that this function
is a constructor. */
#define DECL_CONSTRUCTOR_P(NODE) \
- DECL_CXX_CONSTRUCTOR_P (STRIP_TEMPLATE (NODE))
+ IDENTIFIER_CTOR_P (DECL_NAME (NODE))
/* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete
object. */
@@ -2722,8 +2722,7 @@ struct GTY(()) lang_decl {
specialized in-charge constructor or the specialized not-in-charge
constructor. */
#define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE) \
- (DECL_DECLARES_FUNCTION_P (NODE) && DECL_CONSTRUCTOR_P (NODE) \
- && !DECL_CLONED_FUNCTION_P (NODE))
+ (DECL_NAME (NODE) == ctor_identifier)
/* Nonzero if NODE (a FUNCTION_DECL) is a copy constructor. */
#define DECL_COPY_CONSTRUCTOR_P(NODE) \
@@ -2736,14 +2735,13 @@ struct GTY(()) lang_decl {
/* Nonzero if NODE (a FUNCTION_DECL or TEMPLATE_DECL)
is a destructor. */
#define DECL_DESTRUCTOR_P(NODE) \
- DECL_CXX_DESTRUCTOR_P (STRIP_TEMPLATE (NODE))
+ IDENTIFIER_DTOR_P (DECL_NAME (NODE))
/* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
specialized in-charge constructor, in-charge deleting constructor,
or the base destructor. */
#define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE) \
- (DECL_DECLARES_FUNCTION_P (NODE) && DECL_DESTRUCTOR_P (NODE) \
- && !DECL_CLONED_FUNCTION_P (NODE))
+ (DECL_NAME (NODE) == dtor_identifier)
/* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
object. */
Index: decl.c
===================================================================
--- decl.c (revision 250157)
+++ decl.c (working copy)
@@ -8513,11 +8513,11 @@ grokfndecl (tree ctype,
case sfk_constructor:
case sfk_copy_constructor:
case sfk_move_constructor:
- DECL_CONSTRUCTOR_P (decl) = 1;
+ DECL_CXX_CONSTRUCTOR_P (decl) = 1;
DECL_NAME (decl) = ctor_identifier;
break;
case sfk_destructor:
- DECL_DESTRUCTOR_P (decl) = 1;
+ DECL_CXX_DESTRUCTOR_P (decl) = 1;
DECL_NAME (decl) = dtor_identifier;
break;
default:
Index: decl2.c
===================================================================
--- decl2.c (revision 250157)
+++ decl2.c (working copy)
@@ -342,7 +342,7 @@ grokclassfn (tree ctype, tree function,
DECL_CONTEXT (function) = ctype;
if (flags == DTOR_FLAG)
- DECL_DESTRUCTOR_P (function) = 1;
+ DECL_CXX_DESTRUCTOR_P (function) = 1;
if (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function))
maybe_retrofit_in_chrg (function);
Index: friend.c
===================================================================
--- friend.c (revision 250157)
+++ friend.c (working copy)
@@ -529,7 +529,7 @@ do_friend (tree ctype, tree declarator,
/* A method friend. */
if (flags == NO_SPECIAL && declarator == cname)
- DECL_CONSTRUCTOR_P (decl) = 1;
+ DECL_CXX_CONSTRUCTOR_P (decl) = 1;
grokclassfn (ctype, decl, flags);
Index: method.c
===================================================================
--- method.c (revision 250157)
+++ method.c (working copy)
@@ -137,8 +137,8 @@ make_thunk (tree function, bool this_adj
DECL_SAVED_FUNCTION_DATA (thunk) = NULL;
/* The thunk itself is not a constructor or destructor, even if
the thing it is thunking to is. */
- DECL_DESTRUCTOR_P (thunk) = 0;
- DECL_CONSTRUCTOR_P (thunk) = 0;
+ DECL_CXX_DESTRUCTOR_P (thunk) = 0;
+ DECL_CXX_CONSTRUCTOR_P (thunk) = 0;
DECL_EXTERNAL (thunk) = 1;
DECL_ARTIFICIAL (thunk) = 1;
/* The THUNK is not a pending inline, even if the FUNCTION is. */
@@ -223,8 +223,8 @@ make_alias_for (tree target, tree newid)
if (TREE_CODE (alias) == FUNCTION_DECL)
{
DECL_SAVED_FUNCTION_DATA (alias) = NULL;
- DECL_DESTRUCTOR_P (alias) = 0;
- DECL_CONSTRUCTOR_P (alias) = 0;
+ DECL_CXX_DESTRUCTOR_P (alias) = 0;
+ DECL_CXX_CONSTRUCTOR_P (alias) = 0;
DECL_PENDING_INLINE_P (alias) = 0;
DECL_DECLARED_INLINE_P (alias) = 0;
DECL_INITIAL (alias) = error_mark_node;
@@ -2058,9 +2058,9 @@ implicitly_declare_fn (special_function_
/* Assignment operator. */
SET_OVERLOADED_OPERATOR_CODE (fn, NOP_EXPR);
else if (IDENTIFIER_CTOR_P (name))
- DECL_CONSTRUCTOR_P (fn) = true;
+ DECL_CXX_CONSTRUCTOR_P (fn) = true;
else
- DECL_DESTRUCTOR_P (fn) = true;
+ DECL_CXX_DESTRUCTOR_P (fn) = true;
SET_DECL_ALIGN (fn, MINIMUM_METHOD_BOUNDARY);