aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-02-27 14:05:49 -0700
committerTom Tromey <tromey@adacore.com>2020-02-27 14:56:35 -0700
commit317f712722993375935ff8f992410435fb8e2b27 (patch)
tree26e6a11a42a0409fdc52231aabd3010c10613104 /gdb/dwarf2
parent5f6028029146629b5fd5732e20c600b5837c20a9 (diff)
downloadgdb-317f712722993375935ff8f992410435fb8e2b27.zip
gdb-317f712722993375935ff8f992410435fb8e2b27.tar.gz
gdb-317f712722993375935ff8f992410435fb8e2b27.tar.bz2
Remove field_info::nfields member
I noticed that there's no real reason to have field_info::nfields in the DWARF reader. It simply mirrors information that is already available. This patch removes it, in favor of a convenience method. gdb/ChangeLog 2020-02-27 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (struct field_info) <nfields>: Now a method, not a member. (dwarf2_add_field): Don't update nfields. (dwarf2_attach_fields_to_type, process_structure_scope): Update.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/read.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index c5f0ffa..f52b1dd 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1129,9 +1129,6 @@ struct field_info
std::vector<struct nextfield> fields;
std::vector<struct nextfield> baseclasses;
- /* Number of fields (including baseclasses). */
- int nfields = 0;
-
/* Set if the accessibility of one of the fields is not public. */
int non_public_fields = 0;
@@ -1147,6 +1144,12 @@ struct field_info
/* Nested types defined by this class and the number of elements in this
list. */
std::vector<struct decl_field> nested_types_list;
+
+ /* Return the total number of fields (including baseclasses). */
+ int nfields () const
+ {
+ return fields.size () + baseclasses.size ();
+ }
};
/* Loaded secondary compilation units are kept in memory until they
@@ -14207,8 +14210,6 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
new_field = &fip->fields.back ();
}
- fip->nfields++;
-
attr = dwarf2_attr (die, DW_AT_accessibility, cu);
if (attr != nullptr)
new_field->accessibility = DW_UNSND (attr);
@@ -14468,7 +14469,7 @@ static void
dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
struct dwarf2_cu *cu)
{
- int nfields = fip->nfields;
+ int nfields = fip->nfields ();
/* Record the field count, allocate space for the array of fields,
and create blank accessibility bitfields if necessary. */
@@ -15336,7 +15337,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
}
/* Attach fields and member functions to the type. */
- if (fi.nfields)
+ if (fi.nfields () > 0)
dwarf2_attach_fields_to_type (&fi, type, cu);
if (!fi.fnfieldlists.empty ())
{