diff options
author | Tom Tromey <tromey@adacore.com> | 2025-02-24 12:15:56 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2025-03-18 12:40:58 -0600 |
commit | 545c11e607baeae49d61546ba317c2c460a9c3e7 (patch) | |
tree | 1ef8a6ef47adccde3b5d4517eabac767760b2790 | |
parent | 14e39db031266c570aadef8c61e1abbd17bd96da (diff) | |
download | binutils-545c11e607baeae49d61546ba317c2c460a9c3e7.zip binutils-545c11e607baeae49d61546ba317c2c460a9c3e7.tar.gz binutils-545c11e607baeae49d61546ba317c2c460a9c3e7.tar.bz2 |
Remove is_nonnegative and as_nonnegative
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>
-rw-r--r-- | gdb/dwarf2/attribute.h | 22 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 37 |
2 files changed, 20 insertions, 39 deletions
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 824e92b..4dce04d 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -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. diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e5417db..5075839 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -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) |