]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove is_nonnegative and as_nonnegative
authorTom Tromey <tromey@adacore.com>
Mon, 24 Feb 2025 19:15:56 +0000 (12:15 -0700)
committerTom Tromey <tromey@adacore.com>
Tue, 18 Mar 2025 18:40:58 +0000 (12:40 -0600)
This removes attribute::is_nonnegative and attribute::as_nonnegative
in favor of a call to unsigned_constant.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/dwarf2/attribute.h
gdb/dwarf2/read.c

index 824e92bf9cf991817e4ba0f48aebc211c2106036..4dce04d65bb989cb673220c314721f4b2a6117af 100644 (file)
@@ -91,28 +91,6 @@ struct attribute
     return u.unsnd;
   }
 
-  /* Return true if the value is nonnegative.  Requires that that
-     reprocessing not be needed.  */
-  bool is_nonnegative () const
-  {
-    if (form_is_unsigned ())
-      return true;
-    if (form_is_strictly_signed ())
-      return as_signed () >= 0;
-    return false;
-  }
-
-  /* Return the nonnegative value.  Requires that that reprocessing not be
-     needed.  */
-  ULONGEST as_nonnegative () const
-  {
-    if (form_is_unsigned ())
-      return as_unsigned ();
-    if (form_is_strictly_signed ())
-      return (ULONGEST)as_signed ();
-    gdb_assert (false);
-  }
-
   /* Return non-zero if ATTR's value is a section offset --- classes
      lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
      You may use the as_unsigned method to retrieve such offsets.
index e5417db8d5f938415de960e4623cf3ca35bca736..5075839012338f3bf8f83bbe5f3befc268a2fabb 100644 (file)
@@ -17002,27 +17002,30 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
       attr = dwarf2_attr (die,
                          inlined_func ? DW_AT_call_file : DW_AT_decl_file,
                          &file_cu);
-      if (attr != nullptr && attr->is_nonnegative ())
+      if (attr != nullptr)
        {
-         file_name_index file_index
-           = (file_name_index) attr->as_nonnegative ();
-         struct file_entry *fe;
-
-         if (file_cu->line_header == nullptr)
+         std::optional<ULONGEST> index_cst = attr->unsigned_constant ();
+         if (index_cst.has_value ())
            {
-             file_and_directory fnd (nullptr, nullptr);
-             handle_DW_AT_stmt_list (file_cu->dies, file_cu, fnd, {}, false);
-           }
+             file_name_index file_index = (file_name_index) *index_cst;
+             struct file_entry *fe;
 
-         if (file_cu->line_header != nullptr)
-           fe = file_cu->line_header->file_name_at (file_index);
-         else
-           fe = NULL;
+             if (file_cu->line_header == nullptr)
+               {
+                 file_and_directory fnd (nullptr, nullptr);
+                 handle_DW_AT_stmt_list (file_cu->dies, file_cu, fnd, {}, false);
+               }
 
-         if (fe == NULL)
-           complaint (_("file index out of range"));
-         else
-           sym->set_symtab (fe->symtab);
+             if (file_cu->line_header != nullptr)
+               fe = file_cu->line_header->file_name_at (file_index);
+             else
+               fe = NULL;
+
+             if (fe == NULL)
+               complaint (_("file index out of range"));
+             else
+               sym->set_symtab (fe->symtab);
+           }
        }
 
       switch (die->tag)