aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-06-30 10:43:08 -0700
committerNathan Sidwell <nathan@acm.org>2020-06-30 10:50:05 -0700
commitcc3ae9f5c4c0d449045b39250edab189d0e573d1 (patch)
treeb073381c1d94b3973e8ab53886b4f4e11ad26a85 /gcc/cp/class.c
parentfe03543bfb8c88c3feb8076b5ff1690dc3903878 (diff)
downloadgcc-cc3ae9f5c4c0d449045b39250edab189d0e573d1.zip
gcc-cc3ae9f5c4c0d449045b39250edab189d0e573d1.tar.gz
gcc-cc3ae9f5c4c0d449045b39250edab189d0e573d1.tar.bz2
c++: Tweak function cloning names
On the modules branch I need to expose an intermediate step of the function cloning, but before that it'd be nice to rationalize the names somewhat, now that we also use that API for copying the equality operator. Jason's recent patch caused me some pain by altering the same code. I can only blame myself for not pushing some bits sooner. Anyway, this patch makes the newly renamed copy_fndecl_with_name static, and adds a wrapper copy_operator_fn, that takes an operator code. The cdtor cloning functions are renamed to explicitly note they expect cdtors. A followup patch will move some of the logic from copy_fndecl_with_name to build_cdtor_clones. gcc/cp/ * cp-tree.h (copy_fndecl_with_name): Rename to ... (copy_operatorn_fn): ... this. Change arg type. (clone_function_decl): Rename to ... (clone_cdtor): ... this. * class.c (copy_fndecl_with_name): Make static. (copy_operator_fn): New wrapper. (build_clones): Rename to ... (build_cdtor_clones): ... this. (clone_function_decl): Rename to ... (clone_cdtor): ... this. Adjust build_clones calls. (clone_constructors_and_destructors): Adjust clone_function_decl calls. * method.c (implicitly_declare_fn): Adjust copy_fndecl_with_name call. (lazily_declare_fn): Adjust clone_function_decl call. * pt.c (tsubst_function_decl): Likewise. (instantiate_template_1): Likewise. libcc1/ * libcp1plugin.cc (plugin_build_decl): Adjust clone_function_decl call.
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 94a9585..b0cc027 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -4696,7 +4696,7 @@ check_methods (tree t)
}
}
-tree
+static tree
copy_fndecl_with_name (tree fn, tree name)
{
/* Copy the function. */
@@ -4804,6 +4804,14 @@ copy_fndecl_with_name (tree fn, tree name)
return clone;
}
+/* FN is an operator function, create a variant for CODE. */
+
+tree
+copy_operator_fn (tree fn, tree_code code)
+{
+ return copy_fndecl_with_name (fn, ovl_op_identifier (code));
+}
+
/* FN is a constructor or destructor. Clone the declaration to create
a specialized in-charge or not-in-charge version, as indicated by
NAME. */
@@ -4847,8 +4855,8 @@ build_clone (tree fn, tree name)
/* Build the clones of FN, return the number of clones built. These
will be inserted onto DECL_CHAIN of FN. */
-unsigned
-build_clones (tree fn)
+static unsigned
+build_cdtor_clones (tree fn)
{
unsigned count = 0;
@@ -4891,14 +4899,14 @@ build_clones (tree fn)
CLASSTYPE_MEMBER_VEC. */
void
-clone_function_decl (tree fn, bool update_methods)
+clone_cdtor (tree fn, bool update_methods)
{
/* Avoid inappropriate cloning. */
if (DECL_CHAIN (fn)
&& DECL_CLONED_FUNCTION_P (DECL_CHAIN (fn)))
return;
- unsigned count = build_clones (fn);
+ unsigned count = build_cdtor_clones (fn);
/* Note that this is an abstract function that is never emitted. */
DECL_ABSTRACT_P (fn) = true;
@@ -4998,10 +5006,10 @@ clone_constructors_and_destructors (tree t)
/* While constructors can be via a using declaration, at this point
we no longer need to know that. */
for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
- clone_function_decl (*iter, /*update_methods=*/true);
+ clone_cdtor (*iter, /*update_methods=*/true);
if (tree dtor = CLASSTYPE_DESTRUCTOR (t))
- clone_function_decl (dtor, /*update_methods=*/true);
+ clone_cdtor (dtor, /*update_methods=*/true);
}
/* Deduce noexcept for a destructor DTOR. */