[C++ PATCH] simplify clone predicate

https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00904.html
	* cp-tree.h (DECL_CLONED_FUNCTION_P): Reimplement using
	IDENTIFIER_CDTOR_P, correct documentation.
	(DECL_CLONED_FUNCTION): Directly access field.
	(decl_cloned_function_p): Delete.
	* class.c (decl_cloned_function_p): Delete.
	* pt.c (instantiate_template_1): Check DECL_CHAIN is a decl.

From-SVN: r275727
This commit is contained in:
Nathan Sidwell 2019-09-15 12:24:14 +00:00 committed by Nathan Sidwell
parent f5b72b67cf
commit da903a1610
4 changed files with 19 additions and 43 deletions

View File

@ -1,3 +1,12 @@
2019-09-15 Nathan Sidwell <nathan@acm.org>
* cp-tree.h (DECL_CLONED_FUNCTION_P): Reimplement using
IDENTIFIER_CDTOR_P, correct documentation.
(DECL_CLONED_FUNCTION): Directly access field.
(decl_cloned_function_p): Delete.
* class.c (decl_cloned_function_p): Delete.
* pt.c (instantiate_template_1): Check DECL_CHAIN is a decl.
2019-09-11 Nathan Sidwell <nathan@acm.org>
* c-objcp-common.c (cp-objcp-common.c): Alphababetize and

View File

@ -4701,43 +4701,6 @@ build_clone (tree fn, tree name)
return clone;
}
/* Implementation of DECL_CLONED_FUNCTION and DECL_CLONED_FUNCTION_P, do
not invoke this function directly.
For a non-thunk function, returns the address of the slot for storing
the function it is a clone of. Otherwise returns NULL_TREE.
If JUST_TESTING, looks through TEMPLATE_DECL and returns NULL if
cloned_function is unset. This is to support the separate
DECL_CLONED_FUNCTION and DECL_CLONED_FUNCTION_P modes; using the latter
on a template makes sense, but not the former. */
tree *
decl_cloned_function_p (const_tree decl, bool just_testing)
{
tree *ptr;
if (just_testing)
decl = STRIP_TEMPLATE (decl);
if (TREE_CODE (decl) != FUNCTION_DECL
|| !DECL_LANG_SPECIFIC (decl)
|| DECL_LANG_SPECIFIC (decl)->u.fn.thunk_p)
{
#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
if (!just_testing)
lang_check_failed (__FILE__, __LINE__, __FUNCTION__);
else
#endif
return NULL;
}
ptr = &DECL_LANG_SPECIFIC (decl)->u.fn.u5.cloned_function;
if (just_testing && *ptr == NULL_TREE)
return NULL;
else
return ptr;
}
/* Produce declarations for all appropriate clones of FN. If
UPDATE_METHODS is true, the clones are added to the
CLASSTYPE_MEMBER_VEC. */

View File

@ -2874,13 +2874,17 @@ struct GTY(()) lang_decl {
(DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE) \
|| DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE))
/* Nonzero if NODE (a FUNCTION_DECL) is a cloned constructor or
/* Nonzero if NODE (a _DECL) is a cloned constructor or
destructor. */
#define DECL_CLONED_FUNCTION_P(NODE) (!!decl_cloned_function_p (NODE, true))
#define DECL_CLONED_FUNCTION_P(NODE) \
(DECL_NAME (NODE) \
&& IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
&& !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
/* If DECL_CLONED_FUNCTION_P holds, this is the function that was
cloned. */
#define DECL_CLONED_FUNCTION(NODE) (*decl_cloned_function_p (NODE, false))
#define DECL_CLONED_FUNCTION(NODE) \
(DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->u.fn.u5.cloned_function)
/* Perform an action for each clone of FN, if FN is a function with
clones. This macro should be used like:
@ -6333,7 +6337,6 @@ extern void check_abi_tags (tree);
extern tree missing_abi_tags (tree);
extern void fixup_type_variants (tree);
extern void fixup_attribute_variants (tree);
extern tree* decl_cloned_function_p (const_tree, bool);
extern void clone_function_decl (tree, bool);
extern void adjust_clone_args (tree);
extern void deduce_noexcept_on_destructor (tree);

View File

@ -19905,8 +19905,9 @@ instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain)
instantiate all the alternate entry points as well. We do this
by cloning the instantiation of the main entry point, not by
instantiating the template clones. */
if (DECL_CHAIN (gen_tmpl) && DECL_CLONED_FUNCTION_P (DECL_CHAIN (gen_tmpl)))
clone_function_decl (fndecl, /*update_methods=*/false);
if (tree chain = DECL_CHAIN (gen_tmpl))
if (DECL_P (chain) && DECL_CLONED_FUNCTION_P (chain))
clone_function_decl (fndecl, /*update_methods=*/false);
if (!access_ok)
{