https://gcc.gnu.org/g:2a8af97e3528f812201687334f64b27b94d01271
commit r16-1127-g2a8af97e3528f812201687334f64b27b94d01271 Author: Iain Sandoe <i...@sandoe.co.uk> Date: Thu May 29 16:45:44 2025 +0100 c++, coroutines: Make analyze_fn_params into a class method. 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 <i...@sandoe.co.uk> Diff: --- gcc/cp/coroutines.cc | 20 +++++++++++--------- gcc/cp/coroutines.h | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 8ec309af3ca6..97eee6e8ea4d 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -4027,12 +4027,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. @@ -4042,19 +4044,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; @@ -5249,7 +5251,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, ¶m_uses); + analyze_fn_parms (); /* Declare the actor and destroyer functions, the following code needs to see these. */ diff --git a/gcc/cp/coroutines.h b/gcc/cp/coroutines.h index 10698cf2e129..55caa6e61e36 100644 --- a/gcc/cp/coroutines.h +++ b/gcc/cp/coroutines.h @@ -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 (); };