From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 7AAE7386545E for ; Wed, 24 Mar 2021 14:01:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7AAE7386545E X-ASG-Debug-ID: 1616594506-0c856e6cd5d54080001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 6jVRt4OxS9Gva71c (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 24 Mar 2021 10:01:46 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id 4A016441B21; Wed, 24 Mar 2021 10:01:46 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.181.218 X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/4] gdb: add type::is_declared_class / type::set_is_declared_class Date: Wed, 24 Mar 2021 10:01:42 -0400 X-ASG-Orig-Subj: [PATCH 1/4] gdb: add type::is_declared_class / type::set_is_declared_class Message-Id: <20210324140145.2328183-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1616594506 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 3451 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.88750 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-22.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Mar 2021 14:01:48 -0000 Add the `is_declared_class` and `set_is_declared_class` methods on `struct type`, in order to remove the `TYPE_DECLARED_CLASS` macro. In this patch, the macro is changed to use the getter, so all the call sites of the macro that are used as a setter are changed to use the setter method directly. The next patch will remove the macro completely. gdb/ChangeLog: * gdbtypes.h (struct type) : New methods. (TYPE_DECLARED_CLASS): Use type::is_declared_class, change all write call sites to use type::set_is_declared_class. Change-Id: Idf08d32e137c885a0aba0a18f556a899c1cbfd68 --- gdb/dwarf2/read.c | 4 ++-- gdb/gdbtypes.h | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 2bfb13d6d0e..43669df3cc8 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16145,7 +16145,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) } if (cu->language == language_cplus && die->tag == DW_TAG_class_type) - TYPE_DECLARED_CLASS (type) = 1; + type->set_is_declared_class (true); /* Store the calling convention in the type if it's available in the die. Otherwise the calling convention remains set to @@ -16759,7 +16759,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) set_type_align (type, TYPE_RAW_ALIGN (underlying_type)); } - TYPE_DECLARED_CLASS (type) = dwarf2_flag_true_p (die, DW_AT_enum_class, cu); + type->set_is_declared_class (dwarf2_flag_true_p (die, DW_AT_enum_class, cu)); set_die_type (die, type, cu); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 45014a2b3e8..7444e7ad239 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -226,7 +226,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags); enum types, this is true when "enum class" or "enum struct" was used to declare the type.. */ -#define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class) +#define TYPE_DECLARED_CLASS(t) ((t)->declared_class ()) /* * True if this type is a "flag" enum. A flag enum is one where all the values are pairwise disjoint when "and"ed together. This @@ -815,7 +815,7 @@ struct main_type /* * True if this type was declared with "class" rather than "struct". */ - unsigned int flag_declared_class : 1; + unsigned int m_flag_declared_class : 1; /* * True if this is an enum type with disjoint values. This affects how the enum is printed. */ @@ -1187,6 +1187,23 @@ struct type this->main_type->m_flag_endianity_not_default = endianity_is_not_default; } + + /* True if this type was declared using the "class" keyword. This is + only valid for C++ structure and enum types. If false, a structure + was declared as a "struct"; if true it was declared "class". For + enum types, this is true when "enum class" or "enum struct" was + used to declare the type. */ + + bool is_declared_class () const + { + return this->main_type->m_flag_declared_class; + } + + void set_is_declared_class (bool is_declared_class) const + { + this->main_type->m_flag_declared_class = is_declared_class; + } + /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference to this type's fixed_point_info. */ -- 2.30.0