From: Simon Marchi Date: Fri, 2 Apr 2021 01:10:08 +0000 (-0400) Subject: gdb: add type::is_declared_class / type::set_is_declared_class X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aa70e35c71a2bfa8c2733878b665edb39c171d34;p=binutils-gdb.git gdb: add type::is_declared_class / type::set_is_declared_class 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 --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ac40f8ebb6c..77395fb796f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2021-04-01 Simon Marchi + + * 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. + 2021-02-28 Boris Staletic * gdb/python/lib/gdb/__init__.py: Use importlib on python 3.4+ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index a83c5f94d54..9a90d992cc9 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16147,7 +16147,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 @@ -16761,7 +16761,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. */