mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-14 12:04:04 +08:00
Change is_valid_DW_AT_defaulted to a method on attribute
This changes is_valid_DW_AT_defaulted to be a method on struct attribute. Now it correctly respects the form of the attribute. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (is_valid_DW_AT_defaulted): Move to attribute.c. (dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) <defaulted>: Declare. * dwarf2/attribute.c (attribute::defaulted): New method, from is_valid_DW_AT_defaulted.
This commit is contained in:
parent
d4df075e8b
commit
e8e5c1585d
@ -1,3 +1,11 @@
|
||||
2020-09-29 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* dwarf2/read.c (is_valid_DW_AT_defaulted): Move to attribute.c.
|
||||
(dwarf2_add_member_fn): Update.
|
||||
* dwarf2/attribute.h (struct attribute) <defaulted>: Declare.
|
||||
* dwarf2/attribute.c (attribute::defaulted): New method, from
|
||||
is_valid_DW_AT_defaulted.
|
||||
|
||||
2020-09-29 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* dwarf2/read.c (dw2_get_file_names_reader)
|
||||
|
@ -199,3 +199,26 @@ attribute::form_requires_reprocessing () const
|
||||
|| form == DW_FORM_addrx
|
||||
|| form == DW_FORM_GNU_addr_index);
|
||||
}
|
||||
|
||||
/* See attribute.h. */
|
||||
|
||||
dwarf_defaulted_attribute
|
||||
attribute::defaulted () const
|
||||
{
|
||||
LONGEST value = constant_value (-1);
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case DW_DEFAULTED_no:
|
||||
case DW_DEFAULTED_in_class:
|
||||
case DW_DEFAULTED_out_of_class:
|
||||
return (dwarf_defaulted_attribute) value;
|
||||
}
|
||||
|
||||
/* If the form was not constant, we already complained in
|
||||
constant_value, so there's no need to complain again. */
|
||||
if (form_is_constant ())
|
||||
complaint (_("unrecognized DW_AT_defaulted value (%s)"),
|
||||
plongest (value));
|
||||
return DW_DEFAULTED_no;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "dwarf2.h"
|
||||
#include "gdbtypes.h"
|
||||
#include "gdbsupport/gdb_optional.h"
|
||||
|
||||
/* Blocks are a bunch of untyped bytes. */
|
||||
struct dwarf_block
|
||||
@ -250,6 +251,12 @@ struct attribute
|
||||
return requires_reprocessing;
|
||||
}
|
||||
|
||||
/* Return the value as one of the recognized enum
|
||||
dwarf_defaulted_attribute constants according to DWARF5 spec,
|
||||
Table 7.24. If the value is incorrect, or if this attribute has
|
||||
the wrong form, then a complaint is issued and DW_DEFAULTED_no is
|
||||
returned. */
|
||||
dwarf_defaulted_attribute defaulted () const;
|
||||
|
||||
ENUM_BITFIELD(dwarf_attribute) name : 15;
|
||||
|
||||
|
@ -15538,25 +15538,6 @@ dwarf2_is_constructor (struct die_info *die, struct dwarf2_cu *cu)
|
||||
&& (type_name[len] == '\0' || type_name[len] == '<'));
|
||||
}
|
||||
|
||||
/* Check if the given VALUE is a recognized enum
|
||||
dwarf_defaulted_attribute constant according to DWARF5 spec,
|
||||
Table 7.24. */
|
||||
|
||||
static bool
|
||||
is_valid_DW_AT_defaulted (ULONGEST value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case DW_DEFAULTED_no:
|
||||
case DW_DEFAULTED_in_class:
|
||||
case DW_DEFAULTED_out_of_class:
|
||||
return true;
|
||||
}
|
||||
|
||||
complaint (_("unrecognized DW_AT_defaulted value (%s)"), pulongest (value));
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Add a member function to the proper fieldlist. */
|
||||
|
||||
static void
|
||||
@ -15666,8 +15647,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
|
||||
|
||||
/* Check for defaulted methods. */
|
||||
attr = dwarf2_attr (die, DW_AT_defaulted, cu);
|
||||
if (attr != nullptr && is_valid_DW_AT_defaulted (DW_UNSND (attr)))
|
||||
fnp->defaulted = (enum dwarf_defaulted_attribute) DW_UNSND (attr);
|
||||
if (attr != nullptr)
|
||||
fnp->defaulted = attr->defaulted ();
|
||||
|
||||
/* Check for deleted methods. */
|
||||
attr = dwarf2_attr (die, DW_AT_deleted, cu);
|
||||
|
Loading…
Reference in New Issue
Block a user