Fix some comments in dwarf2/cooked-index.h

Message ID 20240906175501.1801035-1-tromey@adacore.com
State New
Headers
Series Fix some comments in dwarf2/cooked-index.h |

Checks

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

Commit Message

Tom Tromey Sept. 6, 2024, 5:55 p.m. UTC
  This fixes a couple of comments in dwarf2/cooked-index.h.

The comment by cooked_index_entry::canonical mentions C++, but this
field can also be different from 'name' in other situations.  Rather
than enumerate the cases here (which doesn't seem important), make the
text a little less specific.

Also, cooked_index_entry::write_scope doesn't document its "for_main"
parameter -- and it is misnamed in the prototype as well.
---
 gdb/dwarf2/cooked-index.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Tom de Vries Sept. 7, 2024, 1:52 a.m. UTC | #1
On 9/6/24 19:55, Tom Tromey wrote:
> This fixes a couple of comments in dwarf2/cooked-index.h.
> 
> The comment by cooked_index_entry::canonical mentions C++, but this
> field can also be different from 'name' in other situations.  Rather
> than enumerate the cases here (which doesn't seem important), make the
> text a little less specific.
> 
> Also, cooked_index_entry::write_scope doesn't document its "for_main"
> parameter -- and it is misnamed in the prototype as well.

Hi,

LGTM.

Reviewed-By: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> ---
>   gdb/dwarf2/cooked-index.h | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
> index e9f13c97be0..0e63edae1c4 100644
> --- a/gdb/dwarf2/cooked-index.h
> +++ b/gdb/dwarf2/cooked-index.h
> @@ -227,8 +227,7 @@ struct cooked_index_entry : public allocate_on_obstack<cooked_index_entry>
>        linkage name -- two entries are created for DIEs which have both
>        attributes.  */
>     const char *name;
> -  /* The canonical name.  For C++ names, this may differ from NAME.
> -     In all other cases, this is equal to NAME.  */
> +  /* The canonical name.  This may be equal to NAME.  */
>     const char *canonical = nullptr;
>     /* The DWARF tag.  */
>     enum dwarf_tag tag;
> @@ -245,9 +244,10 @@ struct cooked_index_entry : public allocate_on_obstack<cooked_index_entry>
>   
>     /* A helper method for full_name.  Emits the full scope of this
>        object, followed by the separator, to STORAGE.  If this entry has
> -     a parent, its write_scope method is called first.  */
> +     a parent, its write_scope method is called first.  FOR_MAIN is
> +     true when computing the name of 'main'; see full_name.  */
>     void write_scope (struct obstack *storage, const char *sep,
> -		    bool for_name) const;
> +		    bool for_main) const;
>   
>     /* The parent entry.  This is NULL for top-level entries.
>        Otherwise, it points to the parent entry, such as a namespace or
  

Patch

diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index e9f13c97be0..0e63edae1c4 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -227,8 +227,7 @@  struct cooked_index_entry : public allocate_on_obstack<cooked_index_entry>
      linkage name -- two entries are created for DIEs which have both
      attributes.  */
   const char *name;
-  /* The canonical name.  For C++ names, this may differ from NAME.
-     In all other cases, this is equal to NAME.  */
+  /* The canonical name.  This may be equal to NAME.  */
   const char *canonical = nullptr;
   /* The DWARF tag.  */
   enum dwarf_tag tag;
@@ -245,9 +244,10 @@  struct cooked_index_entry : public allocate_on_obstack<cooked_index_entry>
 
   /* A helper method for full_name.  Emits the full scope of this
      object, followed by the separator, to STORAGE.  If this entry has
-     a parent, its write_scope method is called first.  */
+     a parent, its write_scope method is called first.  FOR_MAIN is
+     true when computing the name of 'main'; see full_name.  */
   void write_scope (struct obstack *storage, const char *sep,
-		    bool for_name) const;
+		    bool for_main) const;
 
   /* The parent entry.  This is NULL for top-level entries.
      Otherwise, it points to the parent entry, such as a namespace or