From patchwork Thu Feb 27 21:11:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 38341 Received: (qmail 116379 invoked by alias); 27 Feb 2020 21:11:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 116291 invoked by uid 89); 27 Feb 2020 21:11:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=11299, accessibility, HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Feb 2020 21:11:29 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4F116116FAD; Thu, 27 Feb 2020 16:11:28 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id BLBqm1rPjA8y; Thu, 27 Feb 2020 16:11:28 -0500 (EST) Received: from murgatroyd.Home (75-166-123-50.hlrn.qwest.net [75.166.123.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id A3F83116444; Thu, 27 Feb 2020 16:11:27 -0500 (EST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Remove field_info::nfields member Date: Thu, 27 Feb 2020 14:11:24 -0700 Message-Id: <20200227211124.5097-1-tromey@adacore.com> MIME-Version: 1.0 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 * dwarf2/read.c (struct field_info) : Now a method, not a member. (dwarf2_add_field): Don't update nfields. (dwarf2_attach_fields_to_type, process_structure_scope): Update. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/read.c | 15 ++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index c5f0ffa0d9d..fe0471e331f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1129,9 +1129,6 @@ struct field_info std::vector fields; std::vector 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 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 ()) dwarf2_attach_fields_to_type (&fi, type, cu); if (!fi.fnfieldlists.empty ()) {