* [PATCH 1/6] gdb: remove INIT_NONE_SPECIFIC
2026-03-16 14:25 [PATCH 0/6] Remove some trivial TYPE_* macros Simon Marchi
@ 2026-03-16 14:25 ` Simon Marchi
2026-03-16 14:25 ` [PATCH 2/6] gdb: remove TYPE_MAIN_TYPE Simon Marchi
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2026-03-16 14:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
From: Simon Marchi <simon.marchi@polymtl.ca>
This macro seems unnecessary. It is only used right after allocating a
new type, and it only sets some fields to 0, which is the default state
of a struct type anyway.
Change-Id: I9dab6825b07875964505c387daf5f6b1e12c8144
---
gdb/ada-lang.c | 5 -----
gdb/gdbtypes.h | 4 ----
2 files changed, 9 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 908b33d9c72a..7784f8841318 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7699,7 +7699,6 @@ empty_record (struct type *templ)
struct type *type = type_allocator (templ).new_type ();
type->set_code (TYPE_CODE_STRUCT);
- INIT_NONE_SPECIFIC (type);
type->set_name ("<empty>");
type->set_length (0);
return type;
@@ -7754,7 +7753,6 @@ ada_template_to_fixed_record_type_1 (struct type *type,
rtype = type_allocator (type).new_type ();
rtype->set_code (TYPE_CODE_STRUCT);
- INIT_NONE_SPECIFIC (rtype);
rtype->alloc_fields (nfields);
rtype->set_name (ada_type_name (type));
rtype->set_is_fixed_instance (true);
@@ -8006,8 +8004,6 @@ template_to_static_fixed_type (struct type *type0)
type = type_allocator (type0).new_type ();
type0->set_target_type (type);
type->set_code (type0->code ());
- INIT_NONE_SPECIFIC (type);
-
type->copy_fields (type0);
type->set_name (ada_type_name (type0));
@@ -8053,7 +8049,6 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
rtype = type_allocator (type).new_type ();
rtype->set_code (TYPE_CODE_STRUCT);
- INIT_NONE_SPECIFIC (rtype);
rtype->copy_fields (type);
rtype->set_name (ada_type_name (type));
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index fae89cd2474d..3917b40e3660 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1865,10 +1865,6 @@ extern void allocate_cplus_struct_type (struct type *);
(TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF \
&& TYPE_RAW_CPLUS_SPECIFIC (type) != &cplus_struct_default)
-#define INIT_NONE_SPECIFIC(type) \
- (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_NONE, \
- TYPE_MAIN_TYPE (type)->type_specific = {})
-
extern const struct gnat_aux_type gnat_aux_default;
extern void allocate_gnat_aux_type (struct type *);
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 2/6] gdb: remove TYPE_MAIN_TYPE
2026-03-16 14:25 [PATCH 0/6] Remove some trivial TYPE_* macros Simon Marchi
2026-03-16 14:25 ` [PATCH 1/6] gdb: remove INIT_NONE_SPECIFIC Simon Marchi
@ 2026-03-16 14:25 ` Simon Marchi
2026-03-16 14:25 ` [PATCH 3/6] gdb: remove TYPE_POINTER_TYPE Simon Marchi
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2026-03-16 14:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
From: Simon Marchi <simon.marchi@polymtl.ca>
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: I1076b0e07644afdc0c1f3a4916148d3344a9d395
---
gdb/ada-lang.c | 3 +--
gdb/dwarf2/loc.c | 3 +--
gdb/dwarf2/read.c | 4 ++--
gdb/eval.c | 2 +-
gdb/gdbtypes.c | 48 +++++++++++++++++++++++------------------------
gdb/gdbtypes.h | 21 ++++++++++-----------
6 files changed, 39 insertions(+), 42 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7784f8841318..4ffe69645767 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8570,8 +8570,7 @@ ada_to_fixed_type (struct type *type, const gdb_byte *valaddr,
because we call check_typedef/ada_check_typedef pretty much everywhere.
*/
if (type->code () == TYPE_CODE_TYPEDEF
- && (TYPE_MAIN_TYPE (ada_typedef_target_type (type))
- == TYPE_MAIN_TYPE (fixed_type)))
+ && (ada_typedef_target_type (type)->main_type == fixed_type->main_type))
return type;
return fixed_type;
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 273d3d942b5a..a493a46dcfc9 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1739,8 +1739,7 @@ dwarf2_evaluate_property (const dynamic_prop *prop,
for (pinfo = addr_stack; pinfo != NULL; pinfo = pinfo->next)
{
/* This approach lets us avoid checking the qualifiers. */
- if (TYPE_MAIN_TYPE (pinfo->type)
- == TYPE_MAIN_TYPE (baton->property_type))
+ if (pinfo->type->main_type == baton->property_type->main_type)
break;
}
if (pinfo == NULL)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index e41f06890d74..87f6f33ca071 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -13349,8 +13349,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
/* Only use the attributes if they make sense together. */
if (*bit_size + offset <= 8 * type->length ())
{
- TYPE_MAIN_TYPE (type)->type_specific.int_stuff.bit_size = *bit_size;
- TYPE_MAIN_TYPE (type)->type_specific.int_stuff.bit_offset = offset;
+ type->main_type->type_specific.int_stuff.bit_size = *bit_size;
+ type->main_type->type_specific.int_stuff.bit_offset = offset;
}
}
diff --git a/gdb/eval.c b/gdb/eval.c
index c13f3cb170d3..6cd6f1e677bc 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -455,7 +455,7 @@ fake_method::fake_method (type_instance_flags flags,
{
struct type *type = &m_type;
- TYPE_MAIN_TYPE (type) = &m_main_type;
+ type->main_type = &m_main_type;
type->set_length (1);
type->set_code (TYPE_CODE_METHOD);
TYPE_CHAIN (type) = type;
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 5e07e290f67e..bbefa3ff6b4b 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -216,8 +216,8 @@ type_allocator::new_type ()
/* Alloc the structure and start off with all fields zeroed. */
struct type *type = OBSTACK_ZALLOC (obstack, struct type);
- TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (obstack, struct main_type);
- TYPE_MAIN_TYPE (type)->m_lang = m_lang;
+ type->main_type = OBSTACK_ZALLOC (obstack, struct main_type);
+ type->main_type->m_lang = m_lang;
if (m_is_objfile)
{
@@ -329,7 +329,7 @@ alloc_type_instance (struct type *oldtype)
type = OBSTACK_ZALLOC (&oldtype->objfile_owner ()->objfile_obstack,
struct type);
- TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype);
+ type->main_type = oldtype->main_type;
TYPE_CHAIN (type) = type; /* Chain back to itself for now. */
@@ -346,7 +346,7 @@ smash_type (struct type *type)
objfile *objfile = type->objfile_owner ();
gdbarch *arch = type->arch_owner ();
- memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type));
+ memset (type->main_type, 0, sizeof (struct main_type));
/* Restore owner information. */
if (objfile_owned)
@@ -608,7 +608,7 @@ make_qualified_type (struct type *type, type_instance_flags new_flags,
gdb_assert (type->objfile_owner () == storage->objfile_owner ());
ntype = storage;
- TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type);
+ ntype->main_type = type->main_type;
TYPE_CHAIN (ntype) = ntype;
}
@@ -726,7 +726,7 @@ replace_type (struct type *ntype, struct type *type)
lists; etc.) allocated on an objfile other than its own. */
gdb_assert (ntype->objfile_owner () == type->objfile_owner ());
- *TYPE_MAIN_TYPE (ntype) = *TYPE_MAIN_TYPE (type);
+ *ntype->main_type = *type->main_type;
/* The type length is not a part of the main type. Update it for
each type on the variant chain. */
@@ -1407,12 +1407,12 @@ internal_type_self_type (struct type *type)
if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE)
return NULL;
gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_SELF_TYPE);
- return TYPE_MAIN_TYPE (type)->type_specific.self_type;
+ return type->main_type->type_specific.self_type;
case TYPE_CODE_METHOD:
if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE)
return NULL;
gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_FUNC);
- return TYPE_MAIN_TYPE (type)->type_specific.func_stuff->self_type;
+ return type->main_type->type_specific.func_stuff->self_type;
default:
gdb_assert_not_reached ("bad type");
}
@@ -1433,13 +1433,13 @@ set_type_self_type (struct type *type, struct type *self_type)
if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE)
TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_SELF_TYPE;
gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_SELF_TYPE);
- TYPE_MAIN_TYPE (type)->type_specific.self_type = self_type;
+ type->main_type->type_specific.self_type = self_type;
break;
case TYPE_CODE_METHOD:
if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE)
INIT_FUNC_SPECIFIC (type);
gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_FUNC);
- TYPE_MAIN_TYPE (type)->type_specific.func_stuff->self_type = self_type;
+ type->main_type->type_specific.func_stuff->self_type = self_type;
break;
default:
gdb_assert_not_reached ("bad type");
@@ -2301,12 +2301,12 @@ resolve_dynamic_array_or_string (struct type *type,
struct type *dynamic_array_type = type;
type = copy_type (dynamic_array_type->target_type ());
struct dynamic_prop_list *prop_list
- = TYPE_MAIN_TYPE (dynamic_array_type)->dyn_prop_list;
+ = dynamic_array_type->main_type->dyn_prop_list;
if (prop_list != nullptr)
{
struct obstack *obstack
= &type->objfile_owner ()->objfile_obstack;
- TYPE_MAIN_TYPE (type)->dyn_prop_list
+ type->main_type->dyn_prop_list
= copy_dynamic_prop_list (obstack, prop_list);
}
return type;
@@ -3220,8 +3220,8 @@ init_integer_type (type_allocator &alloc,
t->set_is_unsigned (true);
TYPE_SPECIFIC_FIELD (t) = TYPE_SPECIFIC_INT;
- TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_size = bit;
- TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_offset = 0;
+ t->main_type->type_specific.int_stuff.bit_size = bit;
+ t->main_type->type_specific.int_stuff.bit_offset = 0;
return t;
}
@@ -3254,8 +3254,8 @@ init_boolean_type (type_allocator &alloc,
t->set_is_unsigned (true);
TYPE_SPECIFIC_FIELD (t) = TYPE_SPECIFIC_INT;
- TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_size = bit;
- TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_offset = 0;
+ t->main_type->type_specific.int_stuff.bit_size = bit;
+ t->main_type->type_specific.int_stuff.bit_offset = 0;
return t;
}
@@ -3310,7 +3310,7 @@ init_complex_type (const char *name, struct type *target_type)
gdb_assert (can_create_complex_type (target_type));
- if (TYPE_MAIN_TYPE (target_type)->flds_bnds.complex_type == nullptr)
+ if (target_type->main_type->flds_bnds.complex_type == nullptr)
{
if (name == nullptr && target_type->name () != nullptr)
{
@@ -3331,10 +3331,10 @@ init_complex_type (const char *name, struct type *target_type)
t->set_name (name);
t->set_target_type (target_type);
- TYPE_MAIN_TYPE (target_type)->flds_bnds.complex_type = t;
+ target_type->main_type->flds_bnds.complex_type = t;
}
- return TYPE_MAIN_TYPE (target_type)->flds_bnds.complex_type;
+ return target_type->main_type->flds_bnds.complex_type;
}
/* See gdbtypes.h. */
@@ -3615,7 +3615,7 @@ class_or_union_p (const struct type *t)
int
class_types_same_p (const struct type *a, const struct type *b)
{
- return (TYPE_MAIN_TYPE (a) == TYPE_MAIN_TYPE (b)
+ return (a->main_type == b->main_type
|| (a->name () && b->name ()
&& !strcmp (a->name (), b->name ())));
}
@@ -5234,7 +5234,7 @@ copy_type_recursive (struct type *type, copied_types_hash_t &copied_types)
/* Copy the common fields of types. For the main type, we simply
copy the entire thing and then update specific fields as needed. */
- *TYPE_MAIN_TYPE (new_type) = *TYPE_MAIN_TYPE (type);
+ *new_type->main_type = *type->main_type;
new_type->set_owner (type->arch ());
@@ -5353,8 +5353,8 @@ copy_type_recursive (struct type *type, copied_types_hash_t &copied_types)
break;
case TYPE_SPECIFIC_INT:
TYPE_SPECIFIC_FIELD (new_type) = TYPE_SPECIFIC_INT;
- TYPE_MAIN_TYPE (new_type)->type_specific.int_stuff
- = TYPE_MAIN_TYPE (type)->type_specific.int_stuff;
+ new_type->main_type->type_specific.int_stuff
+ = type->main_type->type_specific.int_stuff;
break;
default:
@@ -5372,7 +5372,7 @@ type_allocator::copy_type (const struct type *type)
struct type *new_type = this->new_type ();
new_type->set_instance_flags (type->instance_flags ());
new_type->set_length (type->length ());
- memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
+ memcpy (new_type->main_type, type->main_type,
sizeof (struct main_type));
/* This might have been overwritten by the memcpy. */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 3917b40e3660..2058f2c8bb94 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1886,9 +1886,9 @@ extern void allocate_gnat_aux_type (struct type *);
#define INIT_FUNC_SPECIFIC(type) \
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
- TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
+ (type)->main_type->type_specific.func_stuff = (struct func_type *) \
TYPE_ZALLOC (type, \
- sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff)))
+ sizeof (*(type)->main_type->type_specific.func_stuff)))
/* "struct fixed_point_type_info" has a field that has a destructor.
See allocate_fixed_point_type_info to understand how this is
@@ -1897,7 +1897,6 @@ extern void allocate_gnat_aux_type (struct type *);
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
allocate_fixed_point_type_info (type))
-#define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
#define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
@@ -1938,7 +1937,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
#define TYPE_SPECIFIC_FIELD(thistype) \
- TYPE_MAIN_TYPE(thistype)->type_specific_field
+ (thistype)->main_type->type_specific_field
/* We need this tap-dance with the TYPE_RAW_SPECIFIC because of the case
where we're trying to print an Ada array using the C language.
In that case, there is no "cplus_stuff", but the C language assumes
@@ -1948,15 +1947,15 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
(!HAVE_CPLUS_STRUCT(thistype) \
? (struct cplus_struct_type*)&cplus_struct_default \
: TYPE_RAW_CPLUS_SPECIFIC(thistype))
-#define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
+#define TYPE_RAW_CPLUS_SPECIFIC(thistype) (thistype)->main_type->type_specific.cplus_stuff
#define TYPE_CPLUS_CALLING_CONVENTION(thistype) \
- TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff->calling_convention
-#define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
-#define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
+ (thistype)->main_type->type_specific.cplus_stuff->calling_convention
+#define TYPE_FLOATFORMAT(thistype) (thistype)->main_type->type_specific.floatformat
+#define TYPE_GNAT_SPECIFIC(thistype) (thistype)->main_type->type_specific.gnat_stuff
#define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
-#define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->calling_convention
-#define TYPE_NO_RETURN(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->is_noreturn
-#define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list
+#define TYPE_CALLING_CONVENTION(thistype) (thistype)->main_type->type_specific.func_stuff->calling_convention
+#define TYPE_NO_RETURN(thistype) (thistype)->main_type->type_specific.func_stuff->is_noreturn
+#define TYPE_TAIL_CALL_LIST(thistype) (thistype)->main_type->type_specific.func_stuff->tail_call_list
#define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ())
#define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
#define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 3/6] gdb: remove TYPE_POINTER_TYPE
2026-03-16 14:25 [PATCH 0/6] Remove some trivial TYPE_* macros Simon Marchi
2026-03-16 14:25 ` [PATCH 1/6] gdb: remove INIT_NONE_SPECIFIC Simon Marchi
2026-03-16 14:25 ` [PATCH 2/6] gdb: remove TYPE_MAIN_TYPE Simon Marchi
@ 2026-03-16 14:25 ` Simon Marchi
2026-03-16 14:25 ` [PATCH 4/6] gdb: remove TYPE_REFERENCE_TYPE Simon Marchi
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2026-03-16 14:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
From: Simon Marchi <simon.marchi@polymtl.ca>
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: I592789130ad81776c7a8b39c4721ebb4aa7293f7
---
gdb/gdbtypes.c | 8 ++++----
gdb/gdbtypes.h | 1 -
gdb/p-exp.y | 2 +-
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index bbefa3ff6b4b..b6b6a95b8a6c 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -368,14 +368,14 @@ make_pointer_type (type *type)
struct type *ntype; /* New type */
struct type *chain;
- ntype = TYPE_POINTER_TYPE (type);
+ ntype = type->pointer_type;
if (ntype)
return ntype;
ntype = type_allocator (type).new_type ();
ntype->set_target_type (type);
- TYPE_POINTER_TYPE (type) = ntype;
+ type->pointer_type = ntype;
/* FIXME! Assumes the machine has only one representation for pointers! */
@@ -614,7 +614,7 @@ make_qualified_type (struct type *type, type_instance_flags new_flags,
/* Pointers or references to the original type are not relevant to
the new type. */
- TYPE_POINTER_TYPE (ntype) = (struct type *) 0;
+ ntype->pointer_type = (struct type *) 0;
TYPE_REFERENCE_TYPE (ntype) = (struct type *) 0;
/* Chain the new qualified type to the old type. */
@@ -4983,7 +4983,7 @@ recursive_dump_type (struct type *type, int spaces)
recursive_dump_type (type->target_type (), spaces + 2);
}
gdb_printf ("%*spointer_type %s\n", spaces, "",
- host_address_to_string (TYPE_POINTER_TYPE (type)));
+ host_address_to_string (type->pointer_type));
gdb_printf ("%*sreference_type %s\n", spaces, "",
host_address_to_string (TYPE_REFERENCE_TYPE (type)));
gdb_printf ("%*stype_chain %s\n", spaces, "",
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 2058f2c8bb94..5bbaa846dc33 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1897,7 +1897,6 @@ extern void allocate_gnat_aux_type (struct type *);
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
allocate_fixed_point_type_info (type))
-#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
#define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
#define TYPE_CHAIN(thistype) (thistype)->chain
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 00b67647fc56..2e24da095c03 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -222,7 +222,7 @@ exp : exp '^' %prec UNARY
exp : '@' exp %prec UNARY
{ pstate->wrap<unop_addr_operation> ();
if (current_type)
- current_type = TYPE_POINTER_TYPE (current_type); }
+ current_type = current_type->pointer_type; }
;
exp : '-' exp %prec UNARY
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 4/6] gdb: remove TYPE_REFERENCE_TYPE
2026-03-16 14:25 [PATCH 0/6] Remove some trivial TYPE_* macros Simon Marchi
` (2 preceding siblings ...)
2026-03-16 14:25 ` [PATCH 3/6] gdb: remove TYPE_POINTER_TYPE Simon Marchi
@ 2026-03-16 14:25 ` Simon Marchi
2026-03-16 14:25 ` [PATCH 5/6] gdb: remove TYPE_RVALUE_REFERENCE_TYPE Simon Marchi
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2026-03-16 14:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
From: Simon Marchi <simon.marchi@polymtl.ca>
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: Iabdb3a3eecd8274ddefc32ad835644bc4a0d2087
---
gdb/gdbtypes.c | 8 ++++----
gdb/gdbtypes.h | 1 -
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b6b6a95b8a6c..feea1e9333be 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -418,7 +418,7 @@ make_reference_type (type *type, type_code refcode)
gdb_assert (refcode == TYPE_CODE_REF || refcode == TYPE_CODE_RVALUE_REF);
- ntype = (refcode == TYPE_CODE_REF ? TYPE_REFERENCE_TYPE (type)
+ ntype = (refcode == TYPE_CODE_REF ? type->reference_type
: TYPE_RVALUE_REFERENCE_TYPE (type));
if (ntype)
@@ -426,7 +426,7 @@ make_reference_type (type *type, type_code refcode)
ntype = type_allocator (type).new_type ();
ntype->set_target_type (type);
- reftype = (refcode == TYPE_CODE_REF ? &TYPE_REFERENCE_TYPE (type)
+ reftype = (refcode == TYPE_CODE_REF ? &type->reference_type
: &TYPE_RVALUE_REFERENCE_TYPE (type));
*reftype = ntype;
@@ -615,7 +615,7 @@ make_qualified_type (struct type *type, type_instance_flags new_flags,
/* Pointers or references to the original type are not relevant to
the new type. */
ntype->pointer_type = (struct type *) 0;
- TYPE_REFERENCE_TYPE (ntype) = (struct type *) 0;
+ ntype->reference_type = nullptr;
/* Chain the new qualified type to the old type. */
TYPE_CHAIN (ntype) = TYPE_CHAIN (type);
@@ -4985,7 +4985,7 @@ recursive_dump_type (struct type *type, int spaces)
gdb_printf ("%*spointer_type %s\n", spaces, "",
host_address_to_string (type->pointer_type));
gdb_printf ("%*sreference_type %s\n", spaces, "",
- host_address_to_string (TYPE_REFERENCE_TYPE (type)));
+ host_address_to_string (type->reference_type));
gdb_printf ("%*stype_chain %s\n", spaces, "",
host_address_to_string (TYPE_CHAIN (type)));
gdb_printf ("%*sinstance_flags 0x%x", spaces, "",
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 5bbaa846dc33..e241da402808 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1897,7 +1897,6 @@ extern void allocate_gnat_aux_type (struct type *);
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
allocate_fixed_point_type_info (type))
-#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
#define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
#define TYPE_CHAIN(thistype) (thistype)->chain
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 5/6] gdb: remove TYPE_RVALUE_REFERENCE_TYPE
2026-03-16 14:25 [PATCH 0/6] Remove some trivial TYPE_* macros Simon Marchi
` (3 preceding siblings ...)
2026-03-16 14:25 ` [PATCH 4/6] gdb: remove TYPE_REFERENCE_TYPE Simon Marchi
@ 2026-03-16 14:25 ` Simon Marchi
2026-03-16 14:25 ` [PATCH 6/6] gdb: remove TYPE_CHAIN Simon Marchi
2026-03-16 17:16 ` [PATCH 0/6] Remove some trivial TYPE_* macros Andrew Burgess
6 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2026-03-16 14:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
From: Simon Marchi <simon.marchi@polymtl.ca>
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: Ic1e6ee65f7fda78a40e935b1e6a8e3b7ab5540fb
---
gdb/gdbtypes.c | 4 ++--
gdb/gdbtypes.h | 1 -
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index feea1e9333be..a32dcfb56991 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -419,7 +419,7 @@ make_reference_type (type *type, type_code refcode)
gdb_assert (refcode == TYPE_CODE_REF || refcode == TYPE_CODE_RVALUE_REF);
ntype = (refcode == TYPE_CODE_REF ? type->reference_type
- : TYPE_RVALUE_REFERENCE_TYPE (type));
+ : type->rvalue_reference_type);
if (ntype)
return ntype;
@@ -427,7 +427,7 @@ make_reference_type (type *type, type_code refcode)
ntype = type_allocator (type).new_type ();
ntype->set_target_type (type);
reftype = (refcode == TYPE_CODE_REF ? &type->reference_type
- : &TYPE_RVALUE_REFERENCE_TYPE (type));
+ : &type->rvalue_reference_type);
*reftype = ntype;
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index e241da402808..afca3c9f6368 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1897,7 +1897,6 @@ extern void allocate_gnat_aux_type (struct type *);
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
allocate_fixed_point_type_info (type))
-#define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
#define TYPE_CHAIN(thistype) (thistype)->chain
/* * Return the alignment of the type in target addressable memory
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 6/6] gdb: remove TYPE_CHAIN
2026-03-16 14:25 [PATCH 0/6] Remove some trivial TYPE_* macros Simon Marchi
` (4 preceding siblings ...)
2026-03-16 14:25 ` [PATCH 5/6] gdb: remove TYPE_RVALUE_REFERENCE_TYPE Simon Marchi
@ 2026-03-16 14:25 ` Simon Marchi
2026-03-16 17:16 ` [PATCH 0/6] Remove some trivial TYPE_* macros Andrew Burgess
6 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2026-03-16 14:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
From: Simon Marchi <simon.marchi@polymtl.ca>
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: Ia45cc7be5c6d9d09a9d4903f01b1ab282839a9c2
---
gdb/eval.c | 2 +-
gdb/gdbtypes.c | 26 +++++++++++++-------------
gdb/gdbtypes.h | 2 --
3 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/gdb/eval.c b/gdb/eval.c
index 6cd6f1e677bc..4ac51399fc89 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -458,7 +458,7 @@ fake_method::fake_method (type_instance_flags flags,
type->main_type = &m_main_type;
type->set_length (1);
type->set_code (TYPE_CODE_METHOD);
- TYPE_CHAIN (type) = type;
+ type->chain = type;
type->set_instance_flags (flags);
if (num_types > 0)
{
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index a32dcfb56991..debecac8edd8 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -229,7 +229,7 @@ type_allocator::new_type ()
/* Initialize the fields that might not be zero. */
type->set_code (TYPE_CODE_UNDEF);
- TYPE_CHAIN (type) = type; /* Chain back to itself. */
+ type->chain = type; /* Chain back to itself. */
return type;
}
@@ -331,7 +331,7 @@ alloc_type_instance (struct type *oldtype)
type->main_type = oldtype->main_type;
- TYPE_CHAIN (type) = type; /* Chain back to itself for now. */
+ type->chain = type; /* Chain back to itself for now. */
return type;
}
@@ -355,7 +355,7 @@ smash_type (struct type *type)
type->set_owner (arch);
/* For now, delete the rings. */
- TYPE_CHAIN (type) = type;
+ type->chain = type;
/* For now, leave the pointer/reference types alone. */
}
@@ -388,11 +388,11 @@ make_pointer_type (type *type)
ntype->set_is_unsigned (true);
/* Update the length of all the other variants of this type. */
- chain = TYPE_CHAIN (ntype);
+ chain = ntype->chain;
while (chain != ntype)
{
chain->set_length (ntype->length ());
- chain = TYPE_CHAIN (chain);
+ chain = chain->chain;
}
return ntype;
@@ -441,11 +441,11 @@ make_reference_type (type *type, type_code refcode)
*reftype = ntype;
/* Update the length of all the other variants of this type. */
- chain = TYPE_CHAIN (ntype);
+ chain = ntype->chain;
while (chain != ntype)
{
chain->set_length (ntype->length ());
- chain = TYPE_CHAIN (chain);
+ chain = chain->chain;
}
return ntype;
@@ -592,7 +592,7 @@ make_qualified_type (struct type *type, type_instance_flags new_flags,
{
if (ntype->instance_flags () == new_flags)
return ntype;
- ntype = TYPE_CHAIN (ntype);
+ ntype = ntype->chain;
}
while (ntype != type);
@@ -609,7 +609,7 @@ make_qualified_type (struct type *type, type_instance_flags new_flags,
ntype = storage;
ntype->main_type = type->main_type;
- TYPE_CHAIN (ntype) = ntype;
+ ntype->chain = ntype;
}
/* Pointers or references to the original type are not relevant to
@@ -618,8 +618,8 @@ make_qualified_type (struct type *type, type_instance_flags new_flags,
ntype->reference_type = nullptr;
/* Chain the new qualified type to the old type. */
- TYPE_CHAIN (ntype) = TYPE_CHAIN (type);
- TYPE_CHAIN (type) = ntype;
+ ntype->chain = type->chain;
+ type->chain = ntype;
/* Now set the instance flags and return the new type. */
ntype->set_instance_flags (new_flags);
@@ -742,7 +742,7 @@ replace_type (struct type *ntype, struct type *type)
gdb_assert (TYPE_ADDRESS_CLASS_ALL (chain) == 0);
chain->set_length (type->length ());
- chain = TYPE_CHAIN (chain);
+ chain = chain->chain;
}
while (ntype != chain);
@@ -4987,7 +4987,7 @@ recursive_dump_type (struct type *type, int spaces)
gdb_printf ("%*sreference_type %s\n", spaces, "",
host_address_to_string (type->reference_type));
gdb_printf ("%*stype_chain %s\n", spaces, "",
- host_address_to_string (TYPE_CHAIN (type)));
+ host_address_to_string (type->chain));
gdb_printf ("%*sinstance_flags 0x%x", spaces, "",
(unsigned) type->instance_flags ());
if (TYPE_CONST (type))
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index afca3c9f6368..139467cfd850 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1897,8 +1897,6 @@ extern void allocate_gnat_aux_type (struct type *);
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
allocate_fixed_point_type_info (type))
-#define TYPE_CHAIN(thistype) (thistype)->chain
-
/* * Return the alignment of the type in target addressable memory
units, or 0 if no alignment was specified. */
#define TYPE_RAW_ALIGN(thistype) type_raw_align (thistype)
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 0/6] Remove some trivial TYPE_* macros
2026-03-16 14:25 [PATCH 0/6] Remove some trivial TYPE_* macros Simon Marchi
` (5 preceding siblings ...)
2026-03-16 14:25 ` [PATCH 6/6] gdb: remove TYPE_CHAIN Simon Marchi
@ 2026-03-16 17:16 ` Andrew Burgess
2026-03-16 17:28 ` Simon Marchi
2026-03-19 14:34 ` Tom Tromey
6 siblings, 2 replies; 10+ messages in thread
From: Andrew Burgess @ 2026-03-16 17:16 UTC (permalink / raw)
To: Simon Marchi, gdb-patches; +Cc: Simon Marchi
Simon Marchi <simon.marchi@efficios.com> writes:
> Here is another small batch of TYPE_* macro removal patches. I think
> that these are simple enough, I'd like to them out of the way first.
I'm happy to see these macros go. Hopefully in the future we'll start
making some more of these type fields private and provide read only
getters where that makes sense. But this seems like a step in the right
direction.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Andrew
>
> Simon Marchi (6):
> gdb: remove INIT_NONE_SPECIFIC
> gdb: remove TYPE_MAIN_TYPE
> gdb: remove TYPE_POINTER_TYPE
> gdb: remove TYPE_REFERENCE_TYPE
> gdb: remove TYPE_RVALUE_REFERENCE_TYPE
> gdb: remove TYPE_CHAIN
>
> gdb/ada-lang.c | 8 +---
> gdb/dwarf2/loc.c | 3 +-
> gdb/dwarf2/read.c | 4 +-
> gdb/eval.c | 4 +-
> gdb/gdbtypes.c | 94 +++++++++++++++++++++++------------------------
> gdb/gdbtypes.h | 30 +++++----------
> gdb/p-exp.y | 2 +-
> 7 files changed, 64 insertions(+), 81 deletions(-)
>
>
> base-commit: 07caff21f90c2f0c9b7b0e79b00b774be668594c
> --
> 2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 0/6] Remove some trivial TYPE_* macros
2026-03-16 17:16 ` [PATCH 0/6] Remove some trivial TYPE_* macros Andrew Burgess
@ 2026-03-16 17:28 ` Simon Marchi
2026-03-19 14:34 ` Tom Tromey
1 sibling, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2026-03-16 17:28 UTC (permalink / raw)
To: Andrew Burgess, gdb-patches
On 3/16/26 1:16 PM, Andrew Burgess wrote:
> Simon Marchi <simon.marchi@efficios.com> writes:
>
>> Here is another small batch of TYPE_* macro removal patches. I think
>> that these are simple enough, I'd like to them out of the way first.
>
> I'm happy to see these macros go. Hopefully in the future we'll start
> making some more of these type fields private and provide read only
> getters where that makes sense. But this seems like a step in the right
> direction.
Yeah, I'd like to get in the "type-specific" ones next, but they are a
bit difficult to untangle.
> Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks, pushed.
Simon
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/6] Remove some trivial TYPE_* macros
2026-03-16 17:16 ` [PATCH 0/6] Remove some trivial TYPE_* macros Andrew Burgess
2026-03-16 17:28 ` Simon Marchi
@ 2026-03-19 14:34 ` Tom Tromey
1 sibling, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2026-03-19 14:34 UTC (permalink / raw)
To: Andrew Burgess; +Cc: Simon Marchi, gdb-patches
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
Andrew> Simon Marchi <simon.marchi@efficios.com> writes:
>> Here is another small batch of TYPE_* macro removal patches. I think
>> that these are simple enough, I'd like to them out of the way first.
Andrew> I'm happy to see these macros go. Hopefully in the future we'll start
Andrew> making some more of these type fields private and provide read only
Andrew> getters where that makes sense.
+1 to that. Ideally we'd use separate subclasses as well but that is a
bit tricky due to type smashing.
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread