Add more comments for variant part code

Message ID 20250320130852.2258791-1-tromey@adacore.com
State New
Headers
Series Add more comments for variant part code |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey March 20, 2025, 1:08 p.m. UTC
  This updates a couple of comments in the DWARF variant part code.
While working in this area I realized I'd forgotten what the arguments
mean.  This attempts to document them.
---
 gdb/dwarf2/read.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)


base-commit: 1b7a712f236504fdc4f741759eb45a21f122aec2
  

Comments

Simon Marchi March 20, 2025, 3:03 p.m. UTC | #1
On 3/20/25 9:08 AM, Tom Tromey wrote:
> This updates a couple of comments in the DWARF variant part code.
> While working in this area I realized I'd forgotten what the arguments
> mean.  This attempts to document them.
> ---
>  gdb/dwarf2/read.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index b9040a57cf9..5675b6a8123 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -11227,7 +11227,11 @@ static void handle_struct_member_die
>     struct dwarf2_cu *cu);
>  
>  /* A helper for handle_struct_member_die that handles
> -   DW_TAG_variant_part.  */
> +   DW_TAG_variant_part.  DIE is the variant part DIE.  TYPE is the
> +   structure type that is being constructed.  FI is the field being
> +   built.  TEMPLATE_ARGS is a pointer to a vector of template
> +   arguments that is being constructed for TYPE.  CU is the DIE's
> +   CU.  */
>  
>  static void
>  handle_variant_part (struct die_info *die, struct type *type,

I think that renaming the variables would go a long way to make the code
itself clearer.  For instance, die -> variant_part_die and type ->
struct_type.

Simon
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b9040a57cf9..5675b6a8123 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -11227,7 +11227,11 @@  static void handle_struct_member_die
    struct dwarf2_cu *cu);
 
 /* A helper for handle_struct_member_die that handles
-   DW_TAG_variant_part.  */
+   DW_TAG_variant_part.  DIE is the variant part DIE.  TYPE is the
+   structure type that is being constructed.  FI is the field being
+   built.  TEMPLATE_ARGS is a pointer to a vector of template
+   arguments that is being constructed for TYPE.  CU is the DIE's
+   CU.  */
 
 static void
 handle_variant_part (struct die_info *die, struct type *type,
@@ -11283,8 +11287,12 @@  handle_variant_part (struct die_info *die, struct type *type,
     handle_struct_member_die (child_die, type, fi, template_args, cu);
 }
 
-/* A helper for handle_struct_member_die that handles
-   DW_TAG_variant.  */
+/* A helper for handle_struct_member_die that handles DW_TAG_variant.
+   DIE is the variant part DIE.  TYPE is the structure type that is
+   being constructed.  FI is the field being built.  TEMPLATE_ARGS is
+   a pointer to a vector of template arguments that is being
+   constructed for TYPE.  CU is the DIE's CU.  */
+
 
 static void
 handle_variant (struct die_info *die, struct type *type,