From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aOdMDkqFDGUPYBoAWB0awg (envelope-from ) for ; Thu, 21 Sep 2023 14:02:50 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=H//LOFte; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 36B7C1E0C3; Thu, 21 Sep 2023 14:02:50 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 239FE1E092 for ; Thu, 21 Sep 2023 14:02:48 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3656385B52A for ; Thu, 21 Sep 2023 18:02:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3656385B52A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695319367; bh=y4/gbRzmX2avxH2PCWzTyao4lwNCX9rntF/YzShRC6A=; h=Date:Subject:References:In-Reply-To:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=H//LOFteJw962kkZF7amnj3+uxFaR4PABcFXMkBBOE8tDCuolhWYmH9b88gp/poBa CeB0VetWA//YdLOngrOuCRMPT7SzLPl/Tyk59lsXTtCwZOQHp9DtJKaJUe5PBL8N8m ac7+ixfsW9LC3Bhy94LVBTrOIsAAvIjAF6DAzEe8= Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id C4F2B3858017 for ; Thu, 21 Sep 2023 18:01:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4F2B3858017 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-792965813e7so48575539f.2 for ; Thu, 21 Sep 2023 11:01:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695319293; x=1695924093; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y4/gbRzmX2avxH2PCWzTyao4lwNCX9rntF/YzShRC6A=; b=TKbhju2OnvKHjv2JE0W9waWjlk3rT+Il8+NL3CYLQlmPmELjwQqNh5/VMiB0xYIsdK 8/14bWc2Wt/+KbE1H0rY5R5hAoKI3ockGCusCCXuh1ioKMJfd1zw27lqV7DxAp7djWgq YPH37R1ZqTe/sg6NBHwYpobEZ3GtJmpFcjaCY6xNHGA3q6jaI07zaz3g7Ic7+VXmTdKr bAtdGo7Us+1bt02OyKo5eis1yWAspLccWz1YiexEldVuuBqYVUbcmTrxRBfqy4I3Aa/e UCD88t+cRqVJzdObQ08rK3OJaBkaP/4NHASK6PiOluaj7FIupswJYNqhrTvc0Q/B1Ik6 abYg== X-Gm-Message-State: AOJu0YxjZArz+k/s+FN7Hm9kLSA8mAioK4cecn9nMct4Fuwlhtrh9p2x 7O4AMkXcRa5tmm2aVm3jak5JfuaGifzi9wYPCPoDSA== X-Google-Smtp-Source: AGHT+IFCTxlm3LhqeM/yiNxz2l9DDUQuxx/Uh0Uncx5+CHIA2FrNhR+c3kIZ1UjrrQSaRmrlL5PX6Q== X-Received: by 2002:a05:6602:42c2:b0:792:792e:6619 with SMTP id ce2-20020a05660242c200b00792792e6619mr6644604iob.2.1695319292943; Thu, 21 Sep 2023 11:01:32 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id q6-20020a02a306000000b0042b52dc77e3sm483736jai.158.2023.09.21.11.01.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 11:01:32 -0700 (PDT) Date: Thu, 21 Sep 2023 12:01:33 -0600 Subject: [PATCH 6/7] Remove some type field accessor macros MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230921-field-bits-v1-6-201285360900@adacore.com> References: <20230921-field-bits-v1-0-201285360900@adacore.com> In-Reply-To: <20230921-field-bits-v1-0-201285360900@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom Tromey via Gdb-patches Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" This removes TYPE_FIELD_PRIVATE, TYPE_FIELD_PROTECTED, TYPE_FIELD_IGNORE, and TYPE_FIELD_VIRTUAL. --- gdb/ada-valprint.c | 2 +- gdb/c-typeprint.c | 10 +++++----- gdb/c-varobj.c | 16 +++++++++------- gdb/compile/compile-cplus-types.c | 7 ++++--- gdb/cp-valprint.c | 4 ++-- gdb/gdbtypes.c | 27 ++++++++++++++------------- gdb/gdbtypes.h | 9 --------- gdb/p-typeprint.c | 6 ++++-- gdb/p-valprint.c | 4 ++-- 9 files changed, 41 insertions(+), 44 deletions(-) diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index eaeca0f6516..686655b18c9 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -619,7 +619,7 @@ print_field_values (struct value *value, struct value *outer_value, { /* Bitfields require special handling, especially due to byte order problems. */ - if (HAVE_CPLUS_STRUCT (type) && TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled (_(""), metadata_style.style (), stream); diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 241fbca49b7..4a0c6950b0c 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -238,7 +238,7 @@ cp_type_print_derivation_info (struct ui_file *stream, gdb_puts (i == 0 ? ": " : ", ", stream); gdb_printf (stream, "%s%s ", BASETYPE_VIA_PUBLIC (type, i) - ? "public" : (TYPE_FIELD_PROTECTED (type, i) + ? "public" : (type->field (i).is_protected () ? "protected" : "private"), BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : ""); name = TYPE_BASECLASS (type, i)->name (); @@ -912,7 +912,7 @@ need_access_label_p (struct type *type) if (type->is_declared_class ()) { for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++) - if (!TYPE_FIELD_PRIVATE (type, i)) + if (!type->field (i).is_private ()) return true; for (int j = 0; j < TYPE_NFN_FIELDS (type); j++) for (int i = 0; i < TYPE_FN_FIELDLIST_LENGTH (type, j); i++) @@ -926,7 +926,7 @@ need_access_label_p (struct type *type) else { for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++) - if (TYPE_FIELD_PRIVATE (type, i) || TYPE_FIELD_PROTECTED (type, i)) + if (!type->field (i).is_public ()) return true; for (int j = 0; j < TYPE_NFN_FIELDS (type); j++) { @@ -1102,8 +1102,8 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, { section_type = output_access_specifier (stream, section_type, level, - TYPE_FIELD_PROTECTED (type, i), - TYPE_FIELD_PRIVATE (type, i), flags); + type->field (i).is_protected (), + type->field (i).is_private (), flags); } bool is_static = type->field (i).is_static (); diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index b00a2345e2c..10edc37c2ea 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -647,16 +647,18 @@ cplus_class_num_children (struct type *type, int children[3]) vptr_fieldno = get_vptr_fieldno (type, &basetype); for (i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++) { + field &fld = type->field (i); + /* If we have a virtual table pointer, omit it. Even if virtual table pointers are not specifically marked in the debug info, they should be artificial. */ if ((type == basetype && i == vptr_fieldno) - || type->field (i).is_artificial ()) + || fld.is_artificial ()) continue; - if (TYPE_FIELD_PROTECTED (type, i)) + if (fld.is_protected ()) children[v_protected]++; - else if (TYPE_FIELD_PRIVATE (type, i)) + else if (fld.is_private ()) children[v_private]++; else children[v_public]++; @@ -677,12 +679,12 @@ enum accessibility { private_field, protected_field, public_field }; static int match_accessibility (struct type *type, int index, enum accessibility acc) { - if (acc == private_field && TYPE_FIELD_PRIVATE (type, index)) + field &fld = type->field (index); + if (acc == private_field && fld.is_private ()) return 1; - else if (acc == protected_field && TYPE_FIELD_PROTECTED (type, index)) + else if (acc == protected_field && fld.is_protected ()) return 1; - else if (acc == public_field && !TYPE_FIELD_PRIVATE (type, index) - && !TYPE_FIELD_PROTECTED (type, index)) + else if (acc == public_field && fld.is_public ()) return 1; else return 0; diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index ac27e83618b..a59d77b76a9 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -73,9 +73,10 @@ compile_cplus_instance::decl_name (const char *natural) static enum gcc_cp_symbol_kind get_field_access_flag (const struct type *type, int num) { - if (TYPE_FIELD_PROTECTED (type, num)) + field &fld = type->field (num); + if (fld.is_protected ()) return GCC_CP_ACCESS_PROTECTED; - else if (TYPE_FIELD_PRIVATE (type, num)) + else if (fld.is_private ()) return GCC_CP_ACCESS_PRIVATE; /* GDB assumes everything else is public. */ @@ -583,7 +584,7 @@ compile_cplus_convert_struct_or_union_members { const char *field_name = type->field (i).name (); - if (TYPE_FIELD_IGNORE (type, i) + if (type->field (i).is_ignored () || type->field (i).is_artificial ()) continue; diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 820a761054a..a803c786d2b 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -265,7 +265,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, /* Bitfields require special handling, especially due to byte order problems. */ - if (TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled ("", metadata_style.style (), stream); @@ -290,7 +290,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, } else { - if (TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled ("", metadata_style.style (), stream); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 55d12218b4e..e9c84004026 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5229,31 +5229,32 @@ recursive_dump_type (struct type *type, int spaces) gdb_printf ("%s\n", host_address_to_string (type->fields ())); for (idx = 0; idx < type->num_fields (); idx++) { + field &fld = type->field (idx); if (type->code () == TYPE_CODE_ENUM) gdb_printf ("%*s[%d] enumval %s type ", spaces + 2, "", - idx, plongest (type->field (idx).loc_enumval ())); + idx, plongest (fld.loc_enumval ())); else gdb_printf ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "", - idx, plongest (type->field (idx).loc_bitpos ()), - type->field (idx).bitsize ()); + idx, plongest (fld.loc_bitpos ()), + fld.bitsize ()); gdb_printf ("%s name '%s' (%s)", - host_address_to_string (type->field (idx).type ()), - type->field (idx).name () != NULL - ? type->field (idx).name () + host_address_to_string (fld.type ()), + fld.name () != NULL + ? fld.name () : "", - host_address_to_string (type->field (idx).name ())); - if (TYPE_FIELD_VIRTUAL (type, idx)) + host_address_to_string (fld.name ())); + if (fld.is_virtual ()) gdb_printf (" virtual"); - if (TYPE_FIELD_PRIVATE (type, idx)) + if (fld.is_private ()) gdb_printf (" private"); - else if (TYPE_FIELD_PROTECTED (type, idx)) + else if (fld.is_protected ()) gdb_printf (" protected"); - else if (TYPE_FIELD_IGNORE (type, idx)) + else if (fld.is_ignored ()) gdb_printf (" ignored"); gdb_printf ("\n"); - if (type->field (idx).type () != NULL) + if (fld.type () != NULL) { - recursive_dump_type (type->field (idx).type (), spaces + 4); + recursive_dump_type (fld.type (), spaces + 4); } } if (type->code () == TYPE_CODE_RANGE) diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 53a8f7e803c..31745f28156 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1973,15 +1973,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *); #define BASETYPE_VIA_VIRTUAL(thistype, index) \ ((thistype)->field (index).is_virtual ()) -#define TYPE_FIELD_PRIVATE(thistype, n) \ - ((thistype)->field (n).is_private ()) -#define TYPE_FIELD_PROTECTED(thistype, n) \ - ((thistype)->field (n).is_protected ()) -#define TYPE_FIELD_IGNORE(thistype, n) \ - ((thistype)->field (n).is_ignored ()) -#define TYPE_FIELD_VIRTUAL(thistype, n) \ - ((thistype)->field (n).is_virtual ()) - #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n] #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index 41058a8b59e..b5d66269d6e 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -486,7 +486,9 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int if (HAVE_CPLUS_STRUCT (type)) { - if (TYPE_FIELD_PROTECTED (type, i)) + field &fld = type->field (i); + + if (fld.is_protected ()) { if (section_type != s_protected) { @@ -495,7 +497,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int level + 2, ""); } } - else if (TYPE_FIELD_PRIVATE (type, i)) + else if (fld.is_private ()) { if (section_type != s_private) { diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index fb9386293a6..05601622560 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -604,7 +604,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, /* Bitfields require special handling, especially due to byte order problems. */ - if (TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled ("", metadata_style.style (), stream); @@ -629,7 +629,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, } else { - if (TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled ("", metadata_style.style (), stream); -- 2.40.1