gdb: add type::code / type::set_code

Add the code and set_code methods on code, in order to remove the
TYPE_CODE macro.  In this patch, the TYPE_CODE macro is changed to use
type::code, so all the call sites that are used to set the type code are
changed to use type::set_code.  The next patch will remove TYPE_CODE
completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <code, set_code>: New methods.
	(TYPE_CODE): Use type::code.  Change all call sites used to set
	the code to use type::set_code instead.
This commit is contained in:
Simon Marchi 2020-05-14 13:45:40 -04:00
parent 02eba61aa6
commit 67607e24d0
12 changed files with 71 additions and 52 deletions

View file

@ -9325,7 +9325,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
/* Smash this type to be a structure type. We have to do this
because the type has already been recorded. */
TYPE_CODE (type) = TYPE_CODE_STRUCT;
type->set_code (TYPE_CODE_STRUCT);
TYPE_NFIELDS (type) = 3;
/* Save the field we care about. */
struct field saved_field = TYPE_FIELD (type, 0);
@ -9368,7 +9368,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
{
/* Smash this type to be a structure type. We have to do this
because the type has already been recorded. */
TYPE_CODE (type) = TYPE_CODE_STRUCT;
type->set_code (TYPE_CODE_STRUCT);
struct type *field_type = TYPE_FIELD_TYPE (type, 0);
const char *variant_name
@ -9415,7 +9415,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
/* Smash this type to be a structure type. We have to do this
because the type has already been recorded. */
TYPE_CODE (type) = TYPE_CODE_STRUCT;
type->set_code (TYPE_CODE_STRUCT);
/* Make space for the discriminant field. */
struct field *disr_field = &TYPE_FIELD (disr_type, 0);
@ -15369,15 +15369,15 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
if (die->tag == DW_TAG_structure_type)
{
TYPE_CODE (type) = TYPE_CODE_STRUCT;
type->set_code (TYPE_CODE_STRUCT);
}
else if (die->tag == DW_TAG_union_type)
{
TYPE_CODE (type) = TYPE_CODE_UNION;
type->set_code (TYPE_CODE_UNION);
}
else
{
TYPE_CODE (type) = TYPE_CODE_STRUCT;
type->set_code (TYPE_CODE_STRUCT);
}
if (cu->language == language_cplus && die->tag == DW_TAG_class_type)
@ -15937,7 +15937,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
type = alloc_type (objfile);
TYPE_CODE (type) = TYPE_CODE_ENUM;
type->set_code (TYPE_CODE_ENUM);
name = dwarf2_full_name (NULL, die, cu);
if (name != NULL)
TYPE_NAME (type) = name;