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

@ -600,9 +600,9 @@ read_structure_type (struct ctf_context *ccp, ctf_id_t tid)
kind = ctf_type_kind (fp, tid);
if (kind == CTF_K_UNION)
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);
TYPE_LENGTH (type) = ctf_type_size (fp, tid);
set_type_align (type, ctf_type_align (fp, tid));
@ -656,7 +656,7 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid)
if (name != NULL && strlen (name.get ()) != 0)
TYPE_NAME (type) = obstack_strdup (&of->objfile_obstack, name.get ());
TYPE_CODE (type) = TYPE_CODE_FUNC;
type->set_code (TYPE_CODE_FUNC);
ctf_func_type_info (fp, tid, &cfi);
rettype = get_tid_type (of, cfi.ctc_return);
TYPE_TARGET_TYPE (type) = rettype;
@ -682,7 +682,7 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid)
if (name != NULL && strlen (name.get ()) != 0)
TYPE_NAME (type) = obstack_strdup (&of->objfile_obstack, name.get ());
TYPE_CODE (type) = TYPE_CODE_ENUM;
type->set_code (TYPE_CODE_ENUM);
TYPE_LENGTH (type) = ctf_type_size (fp, tid);
ctf_func_type_info (fp, tid, &fi);
target_type = get_tid_type (of, fi.ctc_return);