[1/3] Remove language check from dwarf2_compute_name

Message ID 20221107162356.3175221-2-tromey@adacore.com
State Committed
Commit 5f0a4fb85ed3b5fb112ff884a98eb95c685658b0
Headers
Series Fix over-eager CU expansion with new DWARF reader |

Commit Message

Tom Tromey Nov. 7, 2022, 4:23 p.m. UTC
  dwarf2_compute_name has a redundant check of the CU's language -- this
is also checked in dwarf2_canonicalize_name.  Removing this slightly
simplifies a future patch.
---
 gdb/dwarf2/read.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
  

Comments

Andrew Burgess Dec. 1, 2022, 3:16 p.m. UTC | #1
Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

> dwarf2_compute_name has a redundant check of the CU's language -- this
> is also checked in dwarf2_canonicalize_name.  Removing this slightly
> simplifies a future patch.

LGTM.

Thanks,
Andrew

> ---
>  gdb/dwarf2/read.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 60e120a9d76..978dd4d0bb9 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -8918,7 +8918,6 @@ dwarf2_compute_name (const char *name,
>        if (die_needs_namespace (die, cu))
>  	{
>  	  const char *prefix;
> -	  const char *canonical_name = NULL;
>  
>  	  string_file buf;
>  
> @@ -9084,10 +9083,9 @@ dwarf2_compute_name (const char *name,
>  
>  	  const std::string &intermediate_name = buf.string ();
>  
> -	  if (lang == language_cplus)
> -	    canonical_name
> -	      = dwarf2_canonicalize_name (intermediate_name.c_str (), cu,
> -					  objfile);
> +	  const char *canonical_name
> +	    = dwarf2_canonicalize_name (intermediate_name.c_str (), cu,
> +					objfile);
>  
>  	  /* If we only computed INTERMEDIATE_NAME, or if
>  	     INTERMEDIATE_NAME is already canonical, then we need to
> -- 
> 2.34.3
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 60e120a9d76..978dd4d0bb9 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -8918,7 +8918,6 @@  dwarf2_compute_name (const char *name,
       if (die_needs_namespace (die, cu))
 	{
 	  const char *prefix;
-	  const char *canonical_name = NULL;
 
 	  string_file buf;
 
@@ -9084,10 +9083,9 @@  dwarf2_compute_name (const char *name,
 
 	  const std::string &intermediate_name = buf.string ();
 
-	  if (lang == language_cplus)
-	    canonical_name
-	      = dwarf2_canonicalize_name (intermediate_name.c_str (), cu,
-					  objfile);
+	  const char *canonical_name
+	    = dwarf2_canonicalize_name (intermediate_name.c_str (), cu,
+					objfile);
 
 	  /* If we only computed INTERMEDIATE_NAME, or if
 	     INTERMEDIATE_NAME is already canonical, then we need to