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) <is_declared_class,
	set_is_declared_class>: 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
This commit is contained in:
Simon Marchi 2021-04-01 21:10:08 -04:00 committed by Simon Marchi
parent 3451a2d7a3
commit aa70e35c71
3 changed files with 28 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2021-04-01 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (struct type) <is_declared_class,
set_is_declared_class>: 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 <boris.staletic@gmail.com>
* gdb/python/lib/gdb/__init__.py: Use importlib on python 3.4+

View File

@ -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);

View File

@ -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. */