Re: [PATCH 14/20] Change how accessibility is handled in dwarf2/read.c

Simon Marchi
2020-03-30T15:50:40Z

On 2020-03-28 3:22 p.m., Tom Tromey wrote:
> dwarf2/read.c uses dwarf2_default_access_attribute to check for the
> default access attribute. This patch simplifies the code by moving
> more of the access processing into this function, changing its name to
> reflect the difference. This also ensures that the attribute's form
> is respected, by changing to code to use the constant_value method.
>
> gdb/ChangeLog
> 2020-03-28 Tom Tromey <tom@tromey.com>
>
> * dwarf2/read.c (dwarf2_access_attribute): Rename from
> dwarf2_default_access_attribute. Look up attribute.
> (dwarf2_add_field, dwarf2_add_type_defn, dwarf2_add_member_fn):
> Update.
> ---
> gdb/ChangeLog | 7 +++++++
> gdb/dwarf2/read.c | 38 +++++++++++++++++---------------------
> 2 files changed, 24 insertions(+), 21 deletions(-)
>
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index d3897ac2198..efa59fcab4d 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -14001,12 +14001,24 @@ producer_is_codewarrior (struct dwarf2_cu *cu)
> return cu->producer_is_codewarrior;
> }
>
> -/* Return the default accessibility type if it is not overridden by
> +/* Return the accessibility type if it is not overridden by
> DW_AT_accessibility. */

Maybe I don't understand correctly, but I think the "if it is not overridden by
DW_AT_accessibility" part of the comment is no longer true. It's more, return
the value of DW_AT_accessibility, or if it's not present, the default accessibility
value.

Otherwise, LGTM.

Simon