]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove some uses of DW_STRING_IS_CANONICAL
authorTom Tromey <tom@tromey.com>
Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 30 Sep 2020 02:29:06 +0000 (20:29 -0600)
This removes the rvalue uses of DW_STRING_IS_CANONICAL, replacing them
with an accessor method.

gdb/ChangeLog
2020-09-29  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (anonymous_struct_prefix, dwarf2_name)
(dump_die_shallow): Use canonical_string_p.
* dwarf2/attribute.h (struct attribute) <canonical_string_p>: New
method.

gdb/ChangeLog
gdb/dwarf2/attribute.h
gdb/dwarf2/read.c

index f6e0138713f7e5358ae35588e506f0ae776d688e..60cba0b6ea6429ef9e37037b383c3fe24d113158 100644 (file)
@@ -1,3 +1,10 @@
+2020-09-29  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.c (anonymous_struct_prefix, dwarf2_name)
+       (dump_die_shallow): Use canonical_string_p.
+       * dwarf2/attribute.h (struct attribute) <canonical_string_p>: New
+       method.
+
 2020-09-29  Tom Tromey  <tom@tromey.com>
 
        * dwarf2/read.c (partial_die_info::read)
index 86b9136fc13af1e1b94c2d803a8f3050615b0a01..a2c41f2738d525facb1b03f8ee38fb2c26ef1497 100644 (file)
@@ -115,6 +115,16 @@ struct attribute
 
   LONGEST constant_value (int default_value) const;
 
+  /* Return true if this attribute holds a canonical string.  In some
+     cases, like C++ names, gdb will rewrite the name of a DIE to a
+     canonical form.  This makes lookups robust when a name can be
+     spelled different ways (e.g., "signed" or "signed int").  This
+     flag indicates whether the value has been canonicalized.  */
+  bool canonical_string_p () const
+  {
+    return string_is_canonical;
+  }
+
 
   ENUM_BITFIELD(dwarf_attribute) name : 16;
   ENUM_BITFIELD(dwarf_form) form : 15;
index 70d2091148710fe947f80c62c740a7766cb1ae39..f090cb3f8d0d802e50e9a27bf106bcc6f7e6ce7f 100644 (file)
@@ -22312,7 +22312,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_string_p ());
 
   /* Strip the base name, keep any leading namespaces/classes.  */
   base = strrchr (attr_name, ':');
@@ -22638,7 +22638,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
 
          /* Avoid demangling attr_name the second time on a second
             call for the same DIE.  */
-         if (!DW_STRING_IS_CANONICAL (attr))
+         if (!attr->canonical_string_p ())
            {
              gdb::unique_xmalloc_ptr<char> demangled
                (gdb_demangle (attr_name, DMGL_TYPES));
@@ -22664,7 +22664,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
       break;
     }
 
-  if (!DW_STRING_IS_CANONICAL (attr))
+  if (!attr->canonical_string_p ())
     {
       DW_STRING (attr) = dwarf2_canonicalize_name (attr_name, cu,
                                                   objfile);
@@ -22786,7 +22786,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_string_p () ? "is" : "not");
          break;
        case DW_FORM_flag:
          if (DW_UNSND (&die->attrs[i]))