* [PATCH] c++: Prune dead functions.
@ 2021-05-13 22:08 Marek Polacek
2021-05-18 19:12 ` Jason Merrill
0 siblings, 1 reply; 5+ messages in thread
From: Marek Polacek @ 2021-05-13 22:08 UTC (permalink / raw)
To: Jason Merrill, GCC Patches
[ Repost from GCC 11 stage 3. Rebased onto current trunk. ]
I was looking at the LCOV coverage report for the C++ FE and
found a bunch of unused functions that I think we can remove.
Obviously, I left alone various dump_* and debug_* routines.
I haven't removed cp_build_function_call although it is also
currently unused.
* lambda_return_type: was used in parser.c in GCC 7, unused since r255950,
* classtype_has_non_deleted_copy_ctor: appeared in GCC 10, its usage
was removed in c++/95350,
* contains_wildcard_p: used in GCC 9, unused since r276764,
* get_template_head_requirements: seems to never have been used,
* check_constrained_friend: seems to never have been used,
* subsumes_constraints: unused since r276764,
* push_void_library_fn: usage removed in r248328,
* get_template_parms_at_level: unused since r157857,
* get_pattern_parm: unused since r275387.
(Some of the seemingly unused functions, such as set_global_friend, are
actually used in libcc1.)
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
gcc/cp/ChangeLog:
* class.c (classtype_has_non_deleted_copy_ctor): Remove.
* constraint.cc (contains_wildcard_p): Likewise.
(get_template_head_requirements): Likewise.
(check_constrained_friend): Likewise.
(subsumes_constraints): Likewise.
* cp-tree.h (classtype_has_non_deleted_copy_ctor): Likewise.
(push_void_library_fn): Likewise.
(get_pattern_parm): Likewise.
(get_template_parms_at_level): Likewise.
(lambda_return_type): Likewise.
(get_template_head_requirements): Likewise.
(check_constrained_friend): Likewise.
(subsumes_constraints): Likewise.
* decl.c (push_void_library_fn): Likewise.
* lambda.c (lambda_return_type): Likewise.
* pt.c (get_template_parms_at_level): Likewise.
(get_pattern_parm): Likewise.
---
gcc/cp/class.c | 13 ----------
gcc/cp/constraint.cc | 62 --------------------------------------------
gcc/cp/cp-tree.h | 8 ------
gcc/cp/decl.c | 10 -------
gcc/cp/lambda.c | 18 -------------
gcc/cp/pt.c | 49 ----------------------------------
6 files changed, 160 deletions(-)
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 66bc1eea682..354addde773 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5604,19 +5604,6 @@ classtype_has_non_deleted_move_ctor (tree t)
return false;
}
-/* True iff T has a copy constructor that is not deleted. */
-
-bool
-classtype_has_non_deleted_copy_ctor (tree t)
-{
- if (CLASSTYPE_LAZY_COPY_CTOR (t))
- lazily_declare_fn (sfk_copy_constructor, t);
- for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
- if (copy_fn_p (*iter) && !DECL_DELETED_FN (*iter))
- return true;
- return false;
-}
-
/* If T, a class, has a user-provided copy constructor, copy assignment
operator, or destructor, returns that function. Otherwise, null. */
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 30fccc46678..03ce8eb9ff2 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -278,21 +278,6 @@ get_concept_check_template (tree t)
return tmpl;
}
-/* Returns true if any of the arguments in the template argument list is
- a wildcard or wildcard pack. */
-
-bool
-contains_wildcard_p (tree args)
-{
- for (int i = 0; i < TREE_VEC_LENGTH (args); ++i)
- {
- tree arg = TREE_VEC_ELT (args, i);
- if (TREE_CODE (arg) == WILDCARD_DECL)
- return true;
- }
- return false;
-}
-
/*---------------------------------------------------------------------------
Resolution of qualified concept names
---------------------------------------------------------------------------*/
@@ -1310,18 +1295,6 @@ maybe_substitute_reqs_for (tree reqs, const_tree decl_)
return reqs;
}
-/* Returns the template-head requires clause for the template
- declaration T or NULL_TREE if none. */
-
-tree
-get_template_head_requirements (tree t)
-{
- tree ci = get_constraints (t);
- if (!ci)
- return NULL_TREE;
- return CI_TEMPLATE_REQS (ci);
-}
-
/* Returns the trailing requires clause of the declarator of
a template declaration T or NULL_TREE if none. */
@@ -3469,31 +3442,6 @@ check_function_concept (tree fn)
return NULL_TREE;
}
-
-// Check that a constrained friend declaration function declaration,
-// FN, is admissible. This is the case only when the declaration depends
-// on template parameters and does not declare a specialization.
-void
-check_constrained_friend (tree fn, tree reqs)
-{
- if (fn == error_mark_node)
- return;
- gcc_assert (TREE_CODE (fn) == FUNCTION_DECL);
-
- // If there are not constraints, this cannot be an error.
- if (!reqs)
- return;
-
- // Constrained friend functions that don't depend on template
- // arguments are effectively meaningless.
- if (!uses_template_parms (TREE_TYPE (fn)))
- {
- error_at (location_of (fn),
- "constrained friend does not depend on template parameters");
- return;
- }
-}
-
/*---------------------------------------------------------------------------
Equivalence of constraints
---------------------------------------------------------------------------*/
@@ -3521,16 +3469,6 @@ equivalently_constrained (tree d1, tree d2)
Partial ordering of constraints
---------------------------------------------------------------------------*/
-/* Returns true when the constraints in A subsume those in B. */
-
-bool
-subsumes_constraints (tree a, tree b)
-{
- gcc_assert (!a || TREE_CODE (a) == CONSTRAINT_INFO);
- gcc_assert (!b || TREE_CODE (b) == CONSTRAINT_INFO);
- return subsumes (a, b);
-}
-
/* Returns true when the constraints in CI strictly subsume
the associated constraints of TMPL. */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 122dadf976f..860ed795299 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6568,7 +6568,6 @@ extern bool type_has_constexpr_destructor (tree);
extern bool type_has_virtual_destructor (tree);
extern bool classtype_has_move_assign_or_move_ctor_p (tree, bool user_declared);
extern bool classtype_has_non_deleted_move_ctor (tree);
-extern bool classtype_has_non_deleted_copy_ctor (tree);
extern tree classtype_has_depr_implicit_copy (tree);
extern bool classtype_has_op (tree, tree_code);
extern tree classtype_has_defaulted_op (tree, tree_code);
@@ -6654,7 +6653,6 @@ extern void pop_abi_namespace (unsigned flags,
extern tree build_library_fn_ptr (const char *, tree, int);
extern tree build_cp_library_fn_ptr (const char *, tree, int);
extern tree push_library_fn (tree, tree, tree, int);
-extern tree push_void_library_fn (tree, tree, int);
extern tree push_throw_library_fn (tree, tree);
extern void warn_misplaced_attr_for_class_type (location_t location,
tree class_type);
@@ -7178,7 +7176,6 @@ extern tree get_template_info (const_tree);
extern int template_class_depth (tree);
extern int is_specialization_of (tree, tree);
extern bool is_specialization_of_friend (tree, tree);
-extern tree get_pattern_parm (tree, tree);
extern int comp_template_args (tree, tree, tree * = NULL,
tree * = NULL, bool = false);
extern int template_args_equal (tree, tree, bool = false);
@@ -7252,7 +7249,6 @@ bool template_template_parameter_p (const_tree);
bool template_type_parameter_p (const_tree);
extern bool primary_template_specialization_p (const_tree);
extern tree get_primary_template_innermost_parameters (const_tree);
-extern tree get_template_parms_at_level (tree, int);
extern tree get_template_innermost_arguments (const_tree);
extern tree get_template_argument_pack_elems (const_tree);
extern tree get_function_template_decl (const_tree);
@@ -7555,7 +7551,6 @@ extern tree build_lambda_expr (void);
extern tree build_lambda_object (tree);
extern tree begin_lambda_type (tree);
extern tree lambda_capture_field_type (tree, bool, bool);
-extern tree lambda_return_type (tree);
extern tree lambda_proxy_type (tree);
extern tree lambda_function (tree);
extern void apply_deduced_return_type (tree, tree);
@@ -8108,7 +8103,6 @@ extern tree current_template_constraints (void);
extern tree associate_classtype_constraints (tree);
extern tree build_constraints (tree, tree);
extern tree maybe_substitute_reqs_for (tree, const_tree);
-extern tree get_template_head_requirements (tree);
extern tree get_trailing_function_requirements (tree);
extern tree get_shorthand_constraints (tree);
@@ -8134,7 +8128,6 @@ extern tree finish_simple_requirement (location_t, tree);
extern tree finish_type_requirement (location_t, tree);
extern tree finish_compound_requirement (location_t, tree, tree, bool);
extern tree finish_nested_requirement (location_t, tree);
-extern void check_constrained_friend (tree, tree);
extern tree tsubst_requires_expr (tree, tree, tsubst_flags_t, tree);
extern tree evaluate_requires_expr (tree);
extern tree tsubst_constraint (tree, tree, tsubst_flags_t, tree);
@@ -8158,7 +8151,6 @@ extern bool save_subsumption_result (tree, tree, bool);
extern tree find_template_parameters (tree, tree);
extern bool equivalent_constraints (tree, tree);
extern bool equivalently_constrained (tree, tree);
-extern bool subsumes_constraints (tree, tree);
extern bool strictly_subsumes (tree, tree);
extern bool weakly_subsumes (tree, tree);
extern int more_constrained (tree, tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index bc3928d7f85..3c722b411fd 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4963,16 +4963,6 @@ push_cp_library_fn (enum tree_code operator_code, tree type,
return fn;
}
-/* Like push_library_fn, but takes a TREE_LIST of parm types rather than
- a FUNCTION_TYPE. */
-
-tree
-push_void_library_fn (tree name, tree parmtypes, int ecf_flags)
-{
- tree type = build_function_type (void_type_node, parmtypes);
- return push_library_fn (name, type, NULL_TREE, ecf_flags);
-}
-
/* Like push_library_fn, but also note that this function throws
and does not return. Used for __throw_foo and the like. */
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 16e2b4c18b4..4a1e090ead4 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -160,24 +160,6 @@ begin_lambda_type (tree lambda)
return type;
}
-/* Returns the type to use for the return type of the operator() of a
- closure class. */
-
-tree
-lambda_return_type (tree expr)
-{
- if (expr == NULL_TREE)
- return void_type_node;
- if (type_unknown_p (expr)
- || BRACE_ENCLOSED_INITIALIZER_P (expr))
- {
- cxx_incomplete_type_error (expr, TREE_TYPE (expr));
- return error_mark_node;
- }
- gcc_checking_assert (!type_dependent_expression_p (expr));
- return cv_unqualified (type_decays_to (unlowered_expr_type (expr)));
-}
-
/* Given a LAMBDA_EXPR or closure type LAMBDA, return the op() of the
closure type. */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d7d6a3f2c14..6ca0a19d2ac 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3693,25 +3693,6 @@ get_primary_template_innermost_parameters (const_tree t)
return parms;
}
-/* Return the template parameters of the LEVELth level from the full list
- of template parameters PARMS. */
-
-tree
-get_template_parms_at_level (tree parms, int level)
-{
- tree p;
- if (!parms
- || TREE_CODE (parms) != TREE_LIST
- || level > TMPL_PARMS_DEPTH (parms))
- return NULL_TREE;
-
- for (p = parms; p; p = TREE_CHAIN (p))
- if (TMPL_PARMS_DEPTH (p) == level)
- return p;
-
- return NULL_TREE;
-}
-
/* Returns the template arguments of T if T is a template instantiation,
NULL otherwise. */
@@ -13276,36 +13257,6 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
return result;
}
-/* Given PARM_DECL PARM, find the corresponding PARM_DECL in the template
- TMPL. We do this using DECL_PARM_INDEX, which should work even with
- parameter packs; all parms generated from a function parameter pack will
- have the same DECL_PARM_INDEX. */
-
-tree
-get_pattern_parm (tree parm, tree tmpl)
-{
- tree pattern = DECL_TEMPLATE_RESULT (tmpl);
- tree patparm;
-
- if (DECL_ARTIFICIAL (parm))
- {
- for (patparm = DECL_ARGUMENTS (pattern);
- patparm; patparm = DECL_CHAIN (patparm))
- if (DECL_ARTIFICIAL (patparm)
- && DECL_NAME (parm) == DECL_NAME (patparm))
- break;
- }
- else
- {
- patparm = FUNCTION_FIRST_USER_PARM (DECL_TEMPLATE_RESULT (tmpl));
- patparm = chain_index (DECL_PARM_INDEX (parm)-1, patparm);
- gcc_assert (DECL_PARM_INDEX (patparm)
- == DECL_PARM_INDEX (parm));
- }
-
- return patparm;
-}
-
/* Make an argument pack out of the TREE_VEC VEC. */
static tree
base-commit: 1f6fc2826d19136bb5ab97a4bdac07e6736b6869
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] c++: Prune dead functions.
2021-05-13 22:08 [PATCH] c++: Prune dead functions Marek Polacek
@ 2021-05-18 19:12 ` Jason Merrill
0 siblings, 0 replies; 5+ messages in thread
From: Jason Merrill @ 2021-05-18 19:12 UTC (permalink / raw)
To: Marek Polacek, GCC Patches
On 5/13/21 6:08 PM, Marek Polacek wrote:
> [ Repost from GCC 11 stage 3. Rebased onto current trunk. ]
>
> I was looking at the LCOV coverage report for the C++ FE and
> found a bunch of unused functions that I think we can remove.
> Obviously, I left alone various dump_* and debug_* routines.
> I haven't removed cp_build_function_call although it is also
> currently unused.
>
> * lambda_return_type: was used in parser.c in GCC 7, unused since r255950,
> * classtype_has_non_deleted_copy_ctor: appeared in GCC 10, its usage
> was removed in c++/95350,
> * contains_wildcard_p: used in GCC 9, unused since r276764,
> * get_template_head_requirements: seems to never have been used,
> * check_constrained_friend: seems to never have been used,
> * subsumes_constraints: unused since r276764,
> * push_void_library_fn: usage removed in r248328,
> * get_template_parms_at_level: unused since r157857,
> * get_pattern_parm: unused since r275387.
>
> (Some of the seemingly unused functions, such as set_global_friend, are
> actually used in libcc1.)
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
OK.
> gcc/cp/ChangeLog:
>
> * class.c (classtype_has_non_deleted_copy_ctor): Remove.
> * constraint.cc (contains_wildcard_p): Likewise.
> (get_template_head_requirements): Likewise.
> (check_constrained_friend): Likewise.
> (subsumes_constraints): Likewise.
> * cp-tree.h (classtype_has_non_deleted_copy_ctor): Likewise.
> (push_void_library_fn): Likewise.
> (get_pattern_parm): Likewise.
> (get_template_parms_at_level): Likewise.
> (lambda_return_type): Likewise.
> (get_template_head_requirements): Likewise.
> (check_constrained_friend): Likewise.
> (subsumes_constraints): Likewise.
> * decl.c (push_void_library_fn): Likewise.
> * lambda.c (lambda_return_type): Likewise.
> * pt.c (get_template_parms_at_level): Likewise.
> (get_pattern_parm): Likewise.
> ---
> gcc/cp/class.c | 13 ----------
> gcc/cp/constraint.cc | 62 --------------------------------------------
> gcc/cp/cp-tree.h | 8 ------
> gcc/cp/decl.c | 10 -------
> gcc/cp/lambda.c | 18 -------------
> gcc/cp/pt.c | 49 ----------------------------------
> 6 files changed, 160 deletions(-)
>
> diff --git a/gcc/cp/class.c b/gcc/cp/class.c
> index 66bc1eea682..354addde773 100644
> --- a/gcc/cp/class.c
> +++ b/gcc/cp/class.c
> @@ -5604,19 +5604,6 @@ classtype_has_non_deleted_move_ctor (tree t)
> return false;
> }
>
> -/* True iff T has a copy constructor that is not deleted. */
> -
> -bool
> -classtype_has_non_deleted_copy_ctor (tree t)
> -{
> - if (CLASSTYPE_LAZY_COPY_CTOR (t))
> - lazily_declare_fn (sfk_copy_constructor, t);
> - for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
> - if (copy_fn_p (*iter) && !DECL_DELETED_FN (*iter))
> - return true;
> - return false;
> -}
> -
> /* If T, a class, has a user-provided copy constructor, copy assignment
> operator, or destructor, returns that function. Otherwise, null. */
>
> diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
> index 30fccc46678..03ce8eb9ff2 100644
> --- a/gcc/cp/constraint.cc
> +++ b/gcc/cp/constraint.cc
> @@ -278,21 +278,6 @@ get_concept_check_template (tree t)
> return tmpl;
> }
>
> -/* Returns true if any of the arguments in the template argument list is
> - a wildcard or wildcard pack. */
> -
> -bool
> -contains_wildcard_p (tree args)
> -{
> - for (int i = 0; i < TREE_VEC_LENGTH (args); ++i)
> - {
> - tree arg = TREE_VEC_ELT (args, i);
> - if (TREE_CODE (arg) == WILDCARD_DECL)
> - return true;
> - }
> - return false;
> -}
> -
> /*---------------------------------------------------------------------------
> Resolution of qualified concept names
> ---------------------------------------------------------------------------*/
> @@ -1310,18 +1295,6 @@ maybe_substitute_reqs_for (tree reqs, const_tree decl_)
> return reqs;
> }
>
> -/* Returns the template-head requires clause for the template
> - declaration T or NULL_TREE if none. */
> -
> -tree
> -get_template_head_requirements (tree t)
> -{
> - tree ci = get_constraints (t);
> - if (!ci)
> - return NULL_TREE;
> - return CI_TEMPLATE_REQS (ci);
> -}
> -
> /* Returns the trailing requires clause of the declarator of
> a template declaration T or NULL_TREE if none. */
>
> @@ -3469,31 +3442,6 @@ check_function_concept (tree fn)
> return NULL_TREE;
> }
>
> -
> -// Check that a constrained friend declaration function declaration,
> -// FN, is admissible. This is the case only when the declaration depends
> -// on template parameters and does not declare a specialization.
> -void
> -check_constrained_friend (tree fn, tree reqs)
> -{
> - if (fn == error_mark_node)
> - return;
> - gcc_assert (TREE_CODE (fn) == FUNCTION_DECL);
> -
> - // If there are not constraints, this cannot be an error.
> - if (!reqs)
> - return;
> -
> - // Constrained friend functions that don't depend on template
> - // arguments are effectively meaningless.
> - if (!uses_template_parms (TREE_TYPE (fn)))
> - {
> - error_at (location_of (fn),
> - "constrained friend does not depend on template parameters");
> - return;
> - }
> -}
> -
> /*---------------------------------------------------------------------------
> Equivalence of constraints
> ---------------------------------------------------------------------------*/
> @@ -3521,16 +3469,6 @@ equivalently_constrained (tree d1, tree d2)
> Partial ordering of constraints
> ---------------------------------------------------------------------------*/
>
> -/* Returns true when the constraints in A subsume those in B. */
> -
> -bool
> -subsumes_constraints (tree a, tree b)
> -{
> - gcc_assert (!a || TREE_CODE (a) == CONSTRAINT_INFO);
> - gcc_assert (!b || TREE_CODE (b) == CONSTRAINT_INFO);
> - return subsumes (a, b);
> -}
> -
> /* Returns true when the constraints in CI strictly subsume
> the associated constraints of TMPL. */
>
> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
> index 122dadf976f..860ed795299 100644
> --- a/gcc/cp/cp-tree.h
> +++ b/gcc/cp/cp-tree.h
> @@ -6568,7 +6568,6 @@ extern bool type_has_constexpr_destructor (tree);
> extern bool type_has_virtual_destructor (tree);
> extern bool classtype_has_move_assign_or_move_ctor_p (tree, bool user_declared);
> extern bool classtype_has_non_deleted_move_ctor (tree);
> -extern bool classtype_has_non_deleted_copy_ctor (tree);
> extern tree classtype_has_depr_implicit_copy (tree);
> extern bool classtype_has_op (tree, tree_code);
> extern tree classtype_has_defaulted_op (tree, tree_code);
> @@ -6654,7 +6653,6 @@ extern void pop_abi_namespace (unsigned flags,
> extern tree build_library_fn_ptr (const char *, tree, int);
> extern tree build_cp_library_fn_ptr (const char *, tree, int);
> extern tree push_library_fn (tree, tree, tree, int);
> -extern tree push_void_library_fn (tree, tree, int);
> extern tree push_throw_library_fn (tree, tree);
> extern void warn_misplaced_attr_for_class_type (location_t location,
> tree class_type);
> @@ -7178,7 +7176,6 @@ extern tree get_template_info (const_tree);
> extern int template_class_depth (tree);
> extern int is_specialization_of (tree, tree);
> extern bool is_specialization_of_friend (tree, tree);
> -extern tree get_pattern_parm (tree, tree);
> extern int comp_template_args (tree, tree, tree * = NULL,
> tree * = NULL, bool = false);
> extern int template_args_equal (tree, tree, bool = false);
> @@ -7252,7 +7249,6 @@ bool template_template_parameter_p (const_tree);
> bool template_type_parameter_p (const_tree);
> extern bool primary_template_specialization_p (const_tree);
> extern tree get_primary_template_innermost_parameters (const_tree);
> -extern tree get_template_parms_at_level (tree, int);
> extern tree get_template_innermost_arguments (const_tree);
> extern tree get_template_argument_pack_elems (const_tree);
> extern tree get_function_template_decl (const_tree);
> @@ -7555,7 +7551,6 @@ extern tree build_lambda_expr (void);
> extern tree build_lambda_object (tree);
> extern tree begin_lambda_type (tree);
> extern tree lambda_capture_field_type (tree, bool, bool);
> -extern tree lambda_return_type (tree);
> extern tree lambda_proxy_type (tree);
> extern tree lambda_function (tree);
> extern void apply_deduced_return_type (tree, tree);
> @@ -8108,7 +8103,6 @@ extern tree current_template_constraints (void);
> extern tree associate_classtype_constraints (tree);
> extern tree build_constraints (tree, tree);
> extern tree maybe_substitute_reqs_for (tree, const_tree);
> -extern tree get_template_head_requirements (tree);
> extern tree get_trailing_function_requirements (tree);
> extern tree get_shorthand_constraints (tree);
>
> @@ -8134,7 +8128,6 @@ extern tree finish_simple_requirement (location_t, tree);
> extern tree finish_type_requirement (location_t, tree);
> extern tree finish_compound_requirement (location_t, tree, tree, bool);
> extern tree finish_nested_requirement (location_t, tree);
> -extern void check_constrained_friend (tree, tree);
> extern tree tsubst_requires_expr (tree, tree, tsubst_flags_t, tree);
> extern tree evaluate_requires_expr (tree);
> extern tree tsubst_constraint (tree, tree, tsubst_flags_t, tree);
> @@ -8158,7 +8151,6 @@ extern bool save_subsumption_result (tree, tree, bool);
> extern tree find_template_parameters (tree, tree);
> extern bool equivalent_constraints (tree, tree);
> extern bool equivalently_constrained (tree, tree);
> -extern bool subsumes_constraints (tree, tree);
> extern bool strictly_subsumes (tree, tree);
> extern bool weakly_subsumes (tree, tree);
> extern int more_constrained (tree, tree);
> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> index bc3928d7f85..3c722b411fd 100644
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -4963,16 +4963,6 @@ push_cp_library_fn (enum tree_code operator_code, tree type,
> return fn;
> }
>
> -/* Like push_library_fn, but takes a TREE_LIST of parm types rather than
> - a FUNCTION_TYPE. */
> -
> -tree
> -push_void_library_fn (tree name, tree parmtypes, int ecf_flags)
> -{
> - tree type = build_function_type (void_type_node, parmtypes);
> - return push_library_fn (name, type, NULL_TREE, ecf_flags);
> -}
> -
> /* Like push_library_fn, but also note that this function throws
> and does not return. Used for __throw_foo and the like. */
>
> diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
> index 16e2b4c18b4..4a1e090ead4 100644
> --- a/gcc/cp/lambda.c
> +++ b/gcc/cp/lambda.c
> @@ -160,24 +160,6 @@ begin_lambda_type (tree lambda)
> return type;
> }
>
> -/* Returns the type to use for the return type of the operator() of a
> - closure class. */
> -
> -tree
> -lambda_return_type (tree expr)
> -{
> - if (expr == NULL_TREE)
> - return void_type_node;
> - if (type_unknown_p (expr)
> - || BRACE_ENCLOSED_INITIALIZER_P (expr))
> - {
> - cxx_incomplete_type_error (expr, TREE_TYPE (expr));
> - return error_mark_node;
> - }
> - gcc_checking_assert (!type_dependent_expression_p (expr));
> - return cv_unqualified (type_decays_to (unlowered_expr_type (expr)));
> -}
> -
> /* Given a LAMBDA_EXPR or closure type LAMBDA, return the op() of the
> closure type. */
>
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index d7d6a3f2c14..6ca0a19d2ac 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -3693,25 +3693,6 @@ get_primary_template_innermost_parameters (const_tree t)
> return parms;
> }
>
> -/* Return the template parameters of the LEVELth level from the full list
> - of template parameters PARMS. */
> -
> -tree
> -get_template_parms_at_level (tree parms, int level)
> -{
> - tree p;
> - if (!parms
> - || TREE_CODE (parms) != TREE_LIST
> - || level > TMPL_PARMS_DEPTH (parms))
> - return NULL_TREE;
> -
> - for (p = parms; p; p = TREE_CHAIN (p))
> - if (TMPL_PARMS_DEPTH (p) == level)
> - return p;
> -
> - return NULL_TREE;
> -}
> -
> /* Returns the template arguments of T if T is a template instantiation,
> NULL otherwise. */
>
> @@ -13276,36 +13257,6 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
> return result;
> }
>
> -/* Given PARM_DECL PARM, find the corresponding PARM_DECL in the template
> - TMPL. We do this using DECL_PARM_INDEX, which should work even with
> - parameter packs; all parms generated from a function parameter pack will
> - have the same DECL_PARM_INDEX. */
> -
> -tree
> -get_pattern_parm (tree parm, tree tmpl)
> -{
> - tree pattern = DECL_TEMPLATE_RESULT (tmpl);
> - tree patparm;
> -
> - if (DECL_ARTIFICIAL (parm))
> - {
> - for (patparm = DECL_ARGUMENTS (pattern);
> - patparm; patparm = DECL_CHAIN (patparm))
> - if (DECL_ARTIFICIAL (patparm)
> - && DECL_NAME (parm) == DECL_NAME (patparm))
> - break;
> - }
> - else
> - {
> - patparm = FUNCTION_FIRST_USER_PARM (DECL_TEMPLATE_RESULT (tmpl));
> - patparm = chain_index (DECL_PARM_INDEX (parm)-1, patparm);
> - gcc_assert (DECL_PARM_INDEX (patparm)
> - == DECL_PARM_INDEX (parm));
> - }
> -
> - return patparm;
> -}
> -
> /* Make an argument pack out of the TREE_VEC VEC. */
>
> static tree
>
> base-commit: 1f6fc2826d19136bb5ab97a4bdac07e6736b6869
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] c++: Prune dead functions.
2021-03-15 12:31 ` Nathan Sidwell
@ 2021-03-15 14:08 ` Marek Polacek
0 siblings, 0 replies; 5+ messages in thread
From: Marek Polacek @ 2021-03-15 14:08 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: Jason Merrill, GCC Patches
On Mon, Mar 15, 2021 at 08:31:09AM -0400, Nathan Sidwell wrote:
> On 3/11/21 3:58 PM, Marek Polacek via Gcc-patches wrote:
> > I was looking at the LCOV coverage report for the C++ FE and
> > found a bunch of unused functions that I think we can remove.
> > Obviously, I left alone various dump_* and debug_* routines.
> > I haven't removed cp_build_function_call although it is also
> > currently unused.
> >
> > * lambda_return_type: was used in parser.c in GCC 7, unused since r255950,
> > * classtype_has_non_deleted_copy_ctor: appeared in GCC 10, its usage
> > was removed in c++/95350,
> > * contains_wildcard_p: used in GCC 9, unused since r276764,
> > * get_template_head_requirements: seems to never have been used,
> > * check_constrained_friend: seems to never have been used,
> > * subsumes_constraints: unused since r276764,
> > * push_void_library_fn: usage removed in r248328,
> > * get_template_parms_at_level: unused since r157857,
> > * get_pattern_parm: unused since r275387.
> >
> > (Some of the seemingly unused functions, such as set_global_friend, are
> > actually used in libcc1.)
> >
> > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
>
> Stage 1 stuff, IMHO
Works for me, will defer.
Marek
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] c++: Prune dead functions.
2021-03-11 20:58 Marek Polacek
@ 2021-03-15 12:31 ` Nathan Sidwell
2021-03-15 14:08 ` Marek Polacek
0 siblings, 1 reply; 5+ messages in thread
From: Nathan Sidwell @ 2021-03-15 12:31 UTC (permalink / raw)
To: Marek Polacek, Jason Merrill, GCC Patches
On 3/11/21 3:58 PM, Marek Polacek via Gcc-patches wrote:
> I was looking at the LCOV coverage report for the C++ FE and
> found a bunch of unused functions that I think we can remove.
> Obviously, I left alone various dump_* and debug_* routines.
> I haven't removed cp_build_function_call although it is also
> currently unused.
>
> * lambda_return_type: was used in parser.c in GCC 7, unused since r255950,
> * classtype_has_non_deleted_copy_ctor: appeared in GCC 10, its usage
> was removed in c++/95350,
> * contains_wildcard_p: used in GCC 9, unused since r276764,
> * get_template_head_requirements: seems to never have been used,
> * check_constrained_friend: seems to never have been used,
> * subsumes_constraints: unused since r276764,
> * push_void_library_fn: usage removed in r248328,
> * get_template_parms_at_level: unused since r157857,
> * get_pattern_parm: unused since r275387.
>
> (Some of the seemingly unused functions, such as set_global_friend, are
> actually used in libcc1.)
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
Stage 1 stuff, IMHO
>
> gcc/cp/ChangeLog:
>
> * class.c (classtype_has_non_deleted_copy_ctor): Remove.
> * constraint.cc (contains_wildcard_p): Likewise.
> (get_template_head_requirements): Likewise.
> (check_constrained_friend): Likewise.
> (subsumes_constraints): Likewise.
> * cp-tree.h (classtype_has_non_deleted_copy_ctor): Likewise.
> (push_void_library_fn): Likewise.
> (get_pattern_parm): Likewise.
> (get_template_parms_at_level): Likewise.
> (lambda_return_type): Likewise.
> (get_template_head_requirements): Likewise.
> (check_constrained_friend): Likewise.
> (subsumes_constraints): Likewise.
> * decl.c (push_void_library_fn): Likewise.
> * lambda.c (lambda_return_type): Likewise.
> * pt.c (get_template_parms_at_level): Likewise.
> (get_pattern_parm): Likewise.
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] c++: Prune dead functions.
@ 2021-03-11 20:58 Marek Polacek
2021-03-15 12:31 ` Nathan Sidwell
0 siblings, 1 reply; 5+ messages in thread
From: Marek Polacek @ 2021-03-11 20:58 UTC (permalink / raw)
To: Jason Merrill, GCC Patches
I was looking at the LCOV coverage report for the C++ FE and
found a bunch of unused functions that I think we can remove.
Obviously, I left alone various dump_* and debug_* routines.
I haven't removed cp_build_function_call although it is also
currently unused.
* lambda_return_type: was used in parser.c in GCC 7, unused since r255950,
* classtype_has_non_deleted_copy_ctor: appeared in GCC 10, its usage
was removed in c++/95350,
* contains_wildcard_p: used in GCC 9, unused since r276764,
* get_template_head_requirements: seems to never have been used,
* check_constrained_friend: seems to never have been used,
* subsumes_constraints: unused since r276764,
* push_void_library_fn: usage removed in r248328,
* get_template_parms_at_level: unused since r157857,
* get_pattern_parm: unused since r275387.
(Some of the seemingly unused functions, such as set_global_friend, are
actually used in libcc1.)
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
gcc/cp/ChangeLog:
* class.c (classtype_has_non_deleted_copy_ctor): Remove.
* constraint.cc (contains_wildcard_p): Likewise.
(get_template_head_requirements): Likewise.
(check_constrained_friend): Likewise.
(subsumes_constraints): Likewise.
* cp-tree.h (classtype_has_non_deleted_copy_ctor): Likewise.
(push_void_library_fn): Likewise.
(get_pattern_parm): Likewise.
(get_template_parms_at_level): Likewise.
(lambda_return_type): Likewise.
(get_template_head_requirements): Likewise.
(check_constrained_friend): Likewise.
(subsumes_constraints): Likewise.
* decl.c (push_void_library_fn): Likewise.
* lambda.c (lambda_return_type): Likewise.
* pt.c (get_template_parms_at_level): Likewise.
(get_pattern_parm): Likewise.
---
gcc/cp/class.c | 13 ----------
gcc/cp/constraint.cc | 62 --------------------------------------------
gcc/cp/cp-tree.h | 8 ------
gcc/cp/decl.c | 10 -------
gcc/cp/lambda.c | 18 -------------
gcc/cp/pt.c | 49 ----------------------------------
6 files changed, 160 deletions(-)
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 856e81e3d1a..9fde7ab5bcc 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5630,19 +5630,6 @@ classtype_has_non_deleted_move_ctor (tree t)
return false;
}
-/* True iff T has a copy constructor that is not deleted. */
-
-bool
-classtype_has_non_deleted_copy_ctor (tree t)
-{
- if (CLASSTYPE_LAZY_COPY_CTOR (t))
- lazily_declare_fn (sfk_copy_constructor, t);
- for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
- if (copy_fn_p (*iter) && !DECL_DELETED_FN (*iter))
- return true;
- return false;
-}
-
/* If T, a class, has a user-provided copy constructor, copy assignment
operator, or destructor, returns that function. Otherwise, null. */
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 5cf43bd6c18..3702c49f10b 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -278,21 +278,6 @@ get_concept_check_template (tree t)
return tmpl;
}
-/* Returns true if any of the arguments in the template argument list is
- a wildcard or wildcard pack. */
-
-bool
-contains_wildcard_p (tree args)
-{
- for (int i = 0; i < TREE_VEC_LENGTH (args); ++i)
- {
- tree arg = TREE_VEC_ELT (args, i);
- if (TREE_CODE (arg) == WILDCARD_DECL)
- return true;
- }
- return false;
-}
-
/*---------------------------------------------------------------------------
Resolution of qualified concept names
---------------------------------------------------------------------------*/
@@ -1300,18 +1285,6 @@ maybe_substitute_reqs_for (tree reqs, const_tree decl_)
return reqs;
}
-/* Returns the template-head requires clause for the template
- declaration T or NULL_TREE if none. */
-
-tree
-get_template_head_requirements (tree t)
-{
- tree ci = get_constraints (t);
- if (!ci)
- return NULL_TREE;
- return CI_TEMPLATE_REQS (ci);
-}
-
/* Returns the trailing requires clause of the declarator of
a template declaration T or NULL_TREE if none. */
@@ -3429,31 +3402,6 @@ check_function_concept (tree fn)
return NULL_TREE;
}
-
-// Check that a constrained friend declaration function declaration,
-// FN, is admissible. This is the case only when the declaration depends
-// on template parameters and does not declare a specialization.
-void
-check_constrained_friend (tree fn, tree reqs)
-{
- if (fn == error_mark_node)
- return;
- gcc_assert (TREE_CODE (fn) == FUNCTION_DECL);
-
- // If there are not constraints, this cannot be an error.
- if (!reqs)
- return;
-
- // Constrained friend functions that don't depend on template
- // arguments are effectively meaningless.
- if (!uses_template_parms (TREE_TYPE (fn)))
- {
- error_at (location_of (fn),
- "constrained friend does not depend on template parameters");
- return;
- }
-}
-
/*---------------------------------------------------------------------------
Equivalence of constraints
---------------------------------------------------------------------------*/
@@ -3481,16 +3429,6 @@ equivalently_constrained (tree d1, tree d2)
Partial ordering of constraints
---------------------------------------------------------------------------*/
-/* Returns true when the constraints in A subsume those in B. */
-
-bool
-subsumes_constraints (tree a, tree b)
-{
- gcc_assert (!a || TREE_CODE (a) == CONSTRAINT_INFO);
- gcc_assert (!b || TREE_CODE (b) == CONSTRAINT_INFO);
- return subsumes (a, b);
-}
-
/* Returns true when the constraints in CI strictly subsume
the associated constraints of TMPL. */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 81ff375f8a5..2b99484cece 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6532,7 +6532,6 @@ extern bool type_has_constexpr_destructor (tree);
extern bool type_has_virtual_destructor (tree);
extern bool classtype_has_move_assign_or_move_ctor_p (tree, bool user_declared);
extern bool classtype_has_non_deleted_move_ctor (tree);
-extern bool classtype_has_non_deleted_copy_ctor (tree);
extern tree classtype_has_depr_implicit_copy (tree);
extern bool classtype_has_op (tree, tree_code);
extern tree classtype_has_defaulted_op (tree, tree_code);
@@ -6618,7 +6617,6 @@ extern void pop_abi_namespace (unsigned flags,
extern tree build_library_fn_ptr (const char *, tree, int);
extern tree build_cp_library_fn_ptr (const char *, tree, int);
extern tree push_library_fn (tree, tree, tree, int);
-extern tree push_void_library_fn (tree, tree, int);
extern tree push_throw_library_fn (tree, tree);
extern void warn_misplaced_attr_for_class_type (location_t location,
tree class_type);
@@ -7140,7 +7138,6 @@ extern tree get_template_info (const_tree);
extern int template_class_depth (tree);
extern int is_specialization_of (tree, tree);
extern bool is_specialization_of_friend (tree, tree);
-extern tree get_pattern_parm (tree, tree);
extern int comp_template_args (tree, tree, tree * = NULL,
tree * = NULL, bool = false);
extern int template_args_equal (tree, tree, bool = false);
@@ -7214,7 +7211,6 @@ bool template_template_parameter_p (const_tree);
bool template_type_parameter_p (const_tree);
extern bool primary_template_specialization_p (const_tree);
extern tree get_primary_template_innermost_parameters (const_tree);
-extern tree get_template_parms_at_level (tree, int);
extern tree get_template_innermost_arguments (const_tree);
extern tree get_template_argument_pack_elems (const_tree);
extern tree get_function_template_decl (const_tree);
@@ -7515,7 +7511,6 @@ extern tree build_lambda_expr (void);
extern tree build_lambda_object (tree);
extern tree begin_lambda_type (tree);
extern tree lambda_capture_field_type (tree, bool, bool);
-extern tree lambda_return_type (tree);
extern tree lambda_proxy_type (tree);
extern tree lambda_function (tree);
extern void apply_deduced_return_type (tree, tree);
@@ -8066,7 +8061,6 @@ extern tree current_template_constraints (void);
extern tree associate_classtype_constraints (tree);
extern tree build_constraints (tree, tree);
extern tree maybe_substitute_reqs_for (tree, const_tree);
-extern tree get_template_head_requirements (tree);
extern tree get_trailing_function_requirements (tree);
extern tree get_shorthand_constraints (tree);
@@ -8092,7 +8086,6 @@ extern tree finish_simple_requirement (location_t, tree);
extern tree finish_type_requirement (location_t, tree);
extern tree finish_compound_requirement (location_t, tree, tree, bool);
extern tree finish_nested_requirement (location_t, tree);
-extern void check_constrained_friend (tree, tree);
extern tree tsubst_requires_expr (tree, tree, tsubst_flags_t, tree);
extern tree evaluate_requires_expr (tree);
extern tree tsubst_constraint (tree, tree, tsubst_flags_t, tree);
@@ -8116,7 +8109,6 @@ extern bool save_subsumption_result (tree, tree, bool);
extern tree find_template_parameters (tree, tree);
extern bool equivalent_constraints (tree, tree);
extern bool equivalently_constrained (tree, tree);
-extern bool subsumes_constraints (tree, tree);
extern bool strictly_subsumes (tree, tree);
extern bool weakly_subsumes (tree, tree);
extern int more_constrained (tree, tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 9c7f6e59bbb..6e478392c31 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4955,16 +4955,6 @@ push_cp_library_fn (enum tree_code operator_code, tree type,
return fn;
}
-/* Like push_library_fn, but takes a TREE_LIST of parm types rather than
- a FUNCTION_TYPE. */
-
-tree
-push_void_library_fn (tree name, tree parmtypes, int ecf_flags)
-{
- tree type = build_function_type (void_type_node, parmtypes);
- return push_library_fn (name, type, NULL_TREE, ecf_flags);
-}
-
/* Like push_library_fn, but also note that this function throws
and does not return. Used for __throw_foo and the like. */
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 421685cbc2d..c415f907400 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -159,24 +159,6 @@ begin_lambda_type (tree lambda)
return type;
}
-/* Returns the type to use for the return type of the operator() of a
- closure class. */
-
-tree
-lambda_return_type (tree expr)
-{
- if (expr == NULL_TREE)
- return void_type_node;
- if (type_unknown_p (expr)
- || BRACE_ENCLOSED_INITIALIZER_P (expr))
- {
- cxx_incomplete_type_error (expr, TREE_TYPE (expr));
- return error_mark_node;
- }
- gcc_checking_assert (!type_dependent_expression_p (expr));
- return cv_unqualified (type_decays_to (unlowered_expr_type (expr)));
-}
-
/* Given a LAMBDA_EXPR or closure type LAMBDA, return the op() of the
closure type. */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 5e485f10d19..0d01776f5a2 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3688,25 +3688,6 @@ get_primary_template_innermost_parameters (const_tree t)
return parms;
}
-/* Return the template parameters of the LEVELth level from the full list
- of template parameters PARMS. */
-
-tree
-get_template_parms_at_level (tree parms, int level)
-{
- tree p;
- if (!parms
- || TREE_CODE (parms) != TREE_LIST
- || level > TMPL_PARMS_DEPTH (parms))
- return NULL_TREE;
-
- for (p = parms; p; p = TREE_CHAIN (p))
- if (TMPL_PARMS_DEPTH (p) == level)
- return p;
-
- return NULL_TREE;
-}
-
/* Returns the template arguments of T if T is a template instantiation,
NULL otherwise. */
@@ -13206,36 +13187,6 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
return result;
}
-/* Given PARM_DECL PARM, find the corresponding PARM_DECL in the template
- TMPL. We do this using DECL_PARM_INDEX, which should work even with
- parameter packs; all parms generated from a function parameter pack will
- have the same DECL_PARM_INDEX. */
-
-tree
-get_pattern_parm (tree parm, tree tmpl)
-{
- tree pattern = DECL_TEMPLATE_RESULT (tmpl);
- tree patparm;
-
- if (DECL_ARTIFICIAL (parm))
- {
- for (patparm = DECL_ARGUMENTS (pattern);
- patparm; patparm = DECL_CHAIN (patparm))
- if (DECL_ARTIFICIAL (patparm)
- && DECL_NAME (parm) == DECL_NAME (patparm))
- break;
- }
- else
- {
- patparm = FUNCTION_FIRST_USER_PARM (DECL_TEMPLATE_RESULT (tmpl));
- patparm = chain_index (DECL_PARM_INDEX (parm)-1, patparm);
- gcc_assert (DECL_PARM_INDEX (patparm)
- == DECL_PARM_INDEX (parm));
- }
-
- return patparm;
-}
-
/* Make an argument pack out of the TREE_VEC VEC. */
static tree
base-commit: 5643f6f396ef7f60d317aef07dd98978cec6afd0
--
2.29.2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-05-18 19:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 22:08 [PATCH] c++: Prune dead functions Marek Polacek
2021-05-18 19:12 ` Jason Merrill
-- strict thread matches above, loose matches on Subject: below --
2021-03-11 20:58 Marek Polacek
2021-03-15 12:31 ` Nathan Sidwell
2021-03-15 14:08 ` Marek Polacek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).