[binutils-gdb] Clean up DW_TAG_namelist handling in new_symbol

Tom Tromey tromey@sourceware.org
Thu Feb 20 00:56:32 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e17e25351f1248cd791f54d17db6f81000301bec

commit e17e25351f1248cd791f54d17db6f81000301bec
Author: Tom Tromey <tom@tromey.com>
Date:   Sat Feb 8 12:43:21 2025 -0700

    Clean up DW_TAG_namelist handling in new_symbol
    
    In dwarf2/read.c:new_symbol, DW_TAG_namelist is listed in the same
    part of the "switch" as other tags.  However, it effectively shares no
    code with these.  This patch splits it into its own case.
    
    Longer term I think new_symbol should be split up drastically.

Diff:
---
 gdb/dwarf2/read.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 4e30a5665c6..475269dad57 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -18780,17 +18780,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_union_type:
 	case DW_TAG_set_type:
 	case DW_TAG_enumeration_type:
-	case DW_TAG_namelist:
-	  if (die->tag == DW_TAG_namelist)
-	    {
-	      sym->set_aclass_index (LOC_STATIC);
-	      sym->set_domain (VAR_DOMAIN);
-	    }
-	  else if (cu->lang () == language_c
-		   || cu->lang () == language_cplus
-		   || cu->lang () == language_objc
-		   || cu->lang () == language_opencl
-		   || cu->lang () == language_minimal)
+	  if (cu->lang () == language_c
+	      || cu->lang () == language_cplus
+	      || cu->lang () == language_objc
+	      || cu->lang () == language_opencl
+	      || cu->lang () == language_minimal)
 	    {
 	      /* These languages have a tag namespace.  Note that
 		 there's a special hack for C++ in the matching code,
@@ -18884,6 +18878,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  sym->set_domain (COMMON_BLOCK_DOMAIN);
 	  list_to_add = cu->list_in_scope;
 	  break;
+	case DW_TAG_namelist:
+	  sym->set_aclass_index (LOC_STATIC);
+	  sym->set_domain (VAR_DOMAIN);
+	  list_to_add = cu->list_in_scope;
+	  break;
 	default:
 	  /* Not a tag we recognize.  Hopefully we aren't processing
 	     trash data, but since we must specifically ignore things


More information about the Gdb-cvs mailing list