From 23dca5c3d77252ad8000d749b4457f7e286b8367 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 29 Sep 2020 18:49:08 -0600 Subject: Add attribute::as_virtuality method This adds a new attribute::as_virtuality method and changes the DWARF reader to use it. This also ensures that the attibute's form will now be respected. gdb/ChangeLog 2020-09-29 Tom Tromey * dwarf2/read.c (dwarf2_add_field, dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) : New method. * dwarf2/attribute.c (attribute::as_virtuality): New method. --- gdb/dwarf2/attribute.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'gdb/dwarf2/attribute.c') diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index 1e56139..95c5fe4 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -222,3 +222,26 @@ attribute::defaulted () const plongest (value)); return DW_DEFAULTED_no; } + +/* See attribute.h. */ + +dwarf_virtuality_attribute +attribute::as_virtuality () const +{ + LONGEST value = constant_value (-1); + + switch (value) + { + case DW_VIRTUALITY_none: + case DW_VIRTUALITY_virtual: + case DW_VIRTUALITY_pure_virtual: + return (dwarf_virtuality_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_virtuality value (%s)"), + plongest (value)); + return DW_VIRTUALITY_none; +} -- cgit v1.1