Remove field_info::nfields member
authorTom Tromey <tromey@adacore.com>
Thu, 27 Feb 2020 21:05:49 +0000 (14:05 -0700)
committerTom Tromey <tromey@adacore.com>
Thu, 27 Feb 2020 21:56:35 +0000 (14:56 -0700)
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.

gdb/ChangeLog
gdb/dwarf2/read.c

index 4376161673bf5c5b10264f7bb1f6a8ff1f14f31a..d99c1784f8b7a87eaa4d0be83205f5b37b320637 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2020-02-27  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gdbtypes.c (create_array_type_with_stride): Use std::abs not
index c5f0ffa0d9d804e418d449fd10529c066721883c..f52b1dd3150b61c685e8db3b29bf774c1fe22dd8 100644 (file)
@@ -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 ())
        {
This page took 0.036609 seconds and 4 git commands to generate.