[PATCH 05/20] Remove some uses of DW_STRING_IS_CANONICAL

Tom Tromey tom@tromey.com
Sat Mar 28 19:21:53 GMT 2020


This removes the rvalue uses of DW_STRING_IS_CANONICAL, replacing them
with an accessor method.

2020-03-28  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (anonymous_struct_prefix, dwarf2_name)
	(dump_die_shallow): Use canonical_p.
	* dwarf2/attribute.h (struct attribute) <canonical_p>: New
	method.
---
 gdb/ChangeLog          | 7 +++++++
 gdb/dwarf2/attribute.h | 6 ++++++
 gdb/dwarf2/read.c      | 8 ++++----
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h
index cefd3c5541e..f20540559aa 100644
--- a/gdb/dwarf2/attribute.h
+++ b/gdb/dwarf2/attribute.h
@@ -100,6 +100,12 @@ struct attribute
 
   LONGEST constant_value (int default_value) const;
 
+  /* Return true if this attribute holds a canonical string.  */
+  bool canonical_p () const
+  {
+    return string_is_canonical;
+  }
+
 
   ENUM_BITFIELD(dwarf_attribute) name : 16;
   ENUM_BITFIELD(dwarf_form) form : 15;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index eb5ee98de60..4b102e52e88 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -20934,7 +20934,7 @@ anonymous_struct_prefix (struct die_info *die, struct dwarf2_cu *cu)
     return NULL;
 
   /* dwarf2_name had to be already called.  */
-  gdb_assert (DW_STRING_IS_CANONICAL (attr));
+  gdb_assert (attr->canonical_p ());
 
   /* Strip the base name, keep any leading namespaces/classes.  */
   base = strrchr (attr->string (), ':');
@@ -21262,7 +21262,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
 
 	  /* Avoid demangling attr->string () the second time on a second
 	     call for the same DIE.  */
-	  if (!DW_STRING_IS_CANONICAL (attr))
+	  if (!attr->canonical_p ())
 	    {
 	      gdb::unique_xmalloc_ptr<char> demangled
 		(gdb_demangle (attr->string (), DMGL_TYPES));
@@ -21287,7 +21287,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
       break;
     }
 
-  if (!DW_STRING_IS_CANONICAL (attr))
+  if (!attr->canonical_p ())
     {
       DW_STRING (attr) = dwarf2_canonicalize_name (attr->string (), cu,
 						   objfile);
@@ -21407,7 +21407,7 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
 	  fprintf_unfiltered (f, "string: \"%s\" (%s canonicalized)",
 		   DW_STRING (&die->attrs[i])
 		   ? DW_STRING (&die->attrs[i]) : "",
-		   DW_STRING_IS_CANONICAL (&die->attrs[i]) ? "is" : "not");
+		   die->attrs[i].canonical_p () ? "is" : "not");
 	  break;
 	case DW_FORM_flag:
 	  if (DW_UNSND (&die->attrs[i]))
-- 
2.17.2



More information about the Gdb-patches mailing list