diff mbox series

c++: Simplify uses of LAMBDA_EXPR_EXTRA_SCOPE

Message ID 666e4b66.050a0220.3399b.f47e@mx.google.com
State New
Headers show
Series c++: Simplify uses of LAMBDA_EXPR_EXTRA_SCOPE | expand

Commit Message

Nathaniel Shead June 16, 2024, 2:18 a.m. UTC
No functional change intended; OK for trunk?

-- >8 --

I noticed there already exists a getter to get the scope of a lambda
from its type directly rather than needing to go via
CLASSTYPE_LAMBDA_EXPR, we may as well use it.

gcc/cp/ChangeLog:

	* module.cc (trees_out::get_merge_kind): Use
	LAMBDA_TYPE_EXTRA_SCOPE instead of LAMBDA_EXPR_EXTRA_SCOPE.
	(trees_out::key_mergeable): Likewise.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
---
 gcc/cp/module.cc | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Nathaniel Shead July 7, 2024, 3:04 p.m. UTC | #1
On Sun, Jun 16, 2024 at 12:18:10PM +1000, Nathaniel Shead wrote:
> No functional change intended; OK for trunk?
> 

In retrospect, committing as obvious after bootstrap+regtest.

> -- >8 --
> 
> I noticed there already exists a getter to get the scope of a lambda
> from its type directly rather than needing to go via
> CLASSTYPE_LAMBDA_EXPR, we may as well use it.
> 
> gcc/cp/ChangeLog:
> 
> 	* module.cc (trees_out::get_merge_kind): Use
> 	LAMBDA_TYPE_EXTRA_SCOPE instead of LAMBDA_EXPR_EXTRA_SCOPE.
> 	(trees_out::key_mergeable): Likewise.
> 
> Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
> ---
>  gcc/cp/module.cc | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
> index ea7ad0c1f29..6d6044af199 100644
> --- a/gcc/cp/module.cc
> +++ b/gcc/cp/module.cc
> @@ -10686,9 +10686,7 @@ trees_out::get_merge_kind (tree decl, depset *dep)
>  	       g++.dg/modules/lambda-6_a.C.  */
>  	    if (DECL_IMPLICIT_TYPEDEF_P (STRIP_TEMPLATE (decl))
>  		&& LAMBDA_TYPE_P (TREE_TYPE (decl)))
> -	      if (tree scope
> -		  = LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR
> -					     (TREE_TYPE (decl))))
> +	      if (tree scope = LAMBDA_TYPE_EXTRA_SCOPE (TREE_TYPE (decl)))
>  		{
>  		  /* Lambdas attached to fields are keyed to its class.  */
>  		  if (TREE_CODE (scope) == FIELD_DECL)
> @@ -10993,8 +10991,7 @@ trees_out::key_mergeable (int tag, merge_kind mk, tree decl, tree inner,
>  	case MK_keyed:
>  	  {
>  	    gcc_checking_assert (LAMBDA_TYPE_P (TREE_TYPE (inner)));
> -	    tree scope = LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR
> -						  (TREE_TYPE (inner)));
> +	    tree scope = LAMBDA_TYPE_EXTRA_SCOPE (TREE_TYPE (inner));
>  	    gcc_checking_assert (TREE_CODE (scope) == VAR_DECL
>  				 || TREE_CODE (scope) == FIELD_DECL
>  				 || TREE_CODE (scope) == PARM_DECL
> -- 
> 2.43.2
>
diff mbox series

Patch

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index ea7ad0c1f29..6d6044af199 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -10686,9 +10686,7 @@  trees_out::get_merge_kind (tree decl, depset *dep)
 	       g++.dg/modules/lambda-6_a.C.  */
 	    if (DECL_IMPLICIT_TYPEDEF_P (STRIP_TEMPLATE (decl))
 		&& LAMBDA_TYPE_P (TREE_TYPE (decl)))
-	      if (tree scope
-		  = LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR
-					     (TREE_TYPE (decl))))
+	      if (tree scope = LAMBDA_TYPE_EXTRA_SCOPE (TREE_TYPE (decl)))
 		{
 		  /* Lambdas attached to fields are keyed to its class.  */
 		  if (TREE_CODE (scope) == FIELD_DECL)
@@ -10993,8 +10991,7 @@  trees_out::key_mergeable (int tag, merge_kind mk, tree decl, tree inner,
 	case MK_keyed:
 	  {
 	    gcc_checking_assert (LAMBDA_TYPE_P (TREE_TYPE (inner)));
-	    tree scope = LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR
-						  (TREE_TYPE (inner)));
+	    tree scope = LAMBDA_TYPE_EXTRA_SCOPE (TREE_TYPE (inner));
 	    gcc_checking_assert (TREE_CODE (scope) == VAR_DECL
 				 || TREE_CODE (scope) == FIELD_DECL
 				 || TREE_CODE (scope) == PARM_DECL