diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2024-07-31 14:51:31 +0100 |
---|---|---|
committer | Iain Sandoe <iains@gcc.gnu.org> | 2024-08-02 11:43:59 +0100 |
commit | 00019b88e714c29c387a3f492155366c921474a0 (patch) | |
tree | e84ff8e60bf6ad90079013c286774714d476a6ee /gcc/cp | |
parent | ffd521d8dcddcd4cfe1f0f10890a2cb8b6e6493f (diff) | |
download | gcc-00019b88e714c29c387a3f492155366c921474a0.zip gcc-00019b88e714c29c387a3f492155366c921474a0.tar.gz gcc-00019b88e714c29c387a3f492155366c921474a0.tar.bz2 |
c++, coroutines: Provide a CTOR for a callback object [NFC].
This provides and uses a CTOR to initialize the object used in
tree walks to track local variable uses. This makes the idiom
used consistent.
gcc/cp/ChangeLog:
* coroutines.cc (struct local_vars_frame_data): Add a
CTOR.
(morph_fn_to_coro): Use CTOR for local_vars_frame_data
instead of brace init.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/coroutines.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 78a7204..af03f5e 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -3989,10 +3989,14 @@ struct local_vars_frame_data { tree *field_list; hash_map<tree, local_var_info> *local_var_uses; - unsigned int nest_depth, bind_indx; - location_t loc; - bool saw_capture; - bool local_var_seen; + unsigned int nest_depth = 0; + unsigned int bind_indx = 0; + location_t loc = UNKNOWN_LOCATION; + bool saw_capture = false; + bool local_var_seen = false; + + local_vars_frame_data (tree *_fl, hash_map<tree, local_var_info> *_lvu) + : field_list (_fl), local_var_uses (_lvu) {} }; /* A tree-walk callback that processes one bind expression noting local @@ -4577,8 +4581,6 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) /* Build our dummy coro frame layout. */ coro_frame_type = begin_class_definition (coro_frame_type); - /* The fields for the coro frame. */ - tree field_list = NULL_TREE; /* We need to know, and inspect, each suspend point in the function in several places. It's convenient to place this map out of line @@ -4592,10 +4594,13 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) cp_walk_tree (&fnbody, await_statement_walker, &body_aw_points, NULL); /* 4. Now make space for local vars, this is conservative again, and we - would expect to delete unused entries later. */ + would expect to delete unused entries later. Compose the frame entries + list. */ + + /* The fields for the coro frame. */ + tree field_list = NULL_TREE; hash_map<tree, local_var_info> local_var_uses; - local_vars_frame_data local_vars_data - = {&field_list, &local_var_uses, 0, 0, fn_start, false, false}; + local_vars_frame_data local_vars_data (&field_list, &local_var_uses); cp_walk_tree (&fnbody, register_local_var_uses, &local_vars_data, NULL); /* Tie off the struct for now, so that we can build offsets to the |