Add attribute::as_unsigned method

This introduces a new attribute::as_unsigned method and changes a few
spots to use it.

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

	* dwarf2/read.c (dw2_get_file_names_reader)
	(dwarf2_build_include_psymtabs, handle_DW_AT_stmt_list)
	(dwarf2_cu::setup_type_unit_groups, fill_in_loclist_baton)
	(dwarf2_symbol_mark_computed): Use as_unsigned.
	* dwarf2/attribute.h (struct attribute) <as_unsigned>: New
	method.
	<form_is_section_offset>: Update comment.
This commit is contained in:
Tom Tromey
2020-09-29 18:49:08 -06:00
parent bf23a26804
commit d4df075e8b
3 changed files with 31 additions and 12 deletions

View File

@@ -82,9 +82,18 @@ struct attribute
return u.unsnd;
}
/* Return the unsigned value. Requires that the form be an unsigned
form, and that reprocessing not be needed. */
ULONGEST as_unsigned () const
{
gdb_assert (form_is_unsigned ());
gdb_assert (!requires_reprocessing);
return u.unsnd;
}
/* Return non-zero if ATTR's value is a section offset --- classes
lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
You may use DW_UNSND (attr) to retrieve such offsets.
You may use the as_unsigned method to retrieve such offsets.
Section 7.5.4, "Attribute Encodings", explains that no attribute
may have a value that belongs to more than one of these classes; it