]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++, coroutines: Make analyze_fn_params into a class method.
authorIain Sandoe <iain@sandoe.co.uk>
Thu, 29 May 2025 15:45:44 +0000 (16:45 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Tue, 29 Jul 2025 15:06:37 +0000 (16:06 +0100)
This continues code cleanups and migration to encapsulation of the
whole coroutine transform.

gcc/cp/ChangeLog:

* coroutines.cc (analyze_fn_parms): Move from free function..
(cp_coroutine_transform::analyze_fn_parms):... to method.
(cp_coroutine_transform::apply_transforms): Adjust call to
analyze_fn_parms.
* coroutines.h: Declare analyze_fn_parms.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 2a8af97e3528f812201687334f64b27b94d01271)

gcc/cp/coroutines.cc
gcc/cp/coroutines.h

index deaf32a9398b9be8e1bd96df138ea76ad68ac662..4841c90824aadb11308e89f270ac79a8fe066b7e 100644 (file)
@@ -4044,12 +4044,14 @@ rewrite_param_uses (tree *stmt, int *do_subtree ATTRIBUTE_UNUSED, void *d)
 }
 
 /* Build up a set of info that determines how each param copy will be
-   handled.  */
+   handled.  We store this in a hash map so that we can access it from
+   a tree walk callback that re-writes the original parameters to their
+   copies.  */
 
-static void
-analyze_fn_parms (tree orig, hash_map<tree, param_info> *param_uses)
+void
+cp_coroutine_transform::analyze_fn_parms ()
 {
-  if (!DECL_ARGUMENTS (orig))
+  if (!DECL_ARGUMENTS (orig_fn_decl))
     return;
 
   /* Build a hash map with an entry for each param.
@@ -4059,19 +4061,19 @@ analyze_fn_parms (tree orig, hash_map<tree, param_info> *param_uses)
      Then a tree list of the uses.
      The second two entries start out empty - and only get populated
      when we see uses.  */
-  bool lambda_p = LAMBDA_FUNCTION_P (orig);
+  bool lambda_p = LAMBDA_FUNCTION_P (orig_fn_decl);
 
   /* Count the param copies from 1 as per the std.  */
   unsigned parm_num = 1;
-  for (tree arg = DECL_ARGUMENTS (orig); arg != NULL;
+  for (tree arg = DECL_ARGUMENTS (orig_fn_decl); arg != NULL;
        ++parm_num, arg = DECL_CHAIN (arg))
     {
       bool existed;
-      param_info &parm = param_uses->get_or_insert (arg, &existed);
+      param_info &parm = param_uses.get_or_insert (arg, &existed);
       gcc_checking_assert (!existed);
       parm.body_uses = NULL;
       tree actual_type = TREE_TYPE (arg);
-      actual_type = complete_type_or_else (actual_type, orig);
+      actual_type = complete_type_or_else (actual_type, orig_fn_decl);
       if (actual_type == NULL_TREE)
        actual_type = error_mark_node;
       parm.orig_type = actual_type;
@@ -5266,7 +5268,7 @@ cp_coroutine_transform::apply_transforms ()
 
   /* Collect information on the original function params and their use in the
      function body.  */
-  analyze_fn_parms (orig_fn_decl, &param_uses);
+  analyze_fn_parms ();
 
   /* Declare the actor and destroyer functions, the following code needs to
      see these.  */
index 10698cf2e129dbf4814fbeed348fe27134289031..55caa6e61e36db05e97957278b0c9d7e09c0a2c2 100644 (file)
@@ -126,6 +126,7 @@ private:
   bool inline_p = false;
   bool valid_coroutine = false;
 
+  void analyze_fn_parms ();
   void wrap_original_function_body ();
   bool build_ramp_function ();
 };