]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove TYPE_MAIN_TYPE
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 16 Mar 2026 14:25:19 +0000 (10:25 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 16 Mar 2026 17:24:45 +0000 (13:24 -0400)
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
Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/ada-lang.c
gdb/dwarf2/loc.c
gdb/dwarf2/read.c
gdb/eval.c
gdb/gdbtypes.c
gdb/gdbtypes.h

index 5611e61ee2567db67b0fee4dc92fc587dae2e1d6..4ab2e4d19a82d5b84bf5b7e2c019e734a7e6addc 100644 (file)
@@ -8567,8 +8567,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;
index 273d3d942b5af6d7ef368e6f6ca11e9861fdf905..a493a46dcfc9a466afd932a9a19ab43ebc980f46 100644 (file)
@@ -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)
index 29c601ef2c328298e4c52c37ca6787bed68fb341..8b87d58dd9c51898991e3d4755159d34dbde4f77 100644 (file)
@@ -13348,8 +13348,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;
        }
     }
 
index c47ac2614c5ee14a9da8d7332d185e84e1bea0e7..32b07f91883ff0149158888aa15a31fc7706b203 100644 (file)
@@ -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;
index 0ad06f56c30d3830ddbc12097a64f1889101f89d..896b3afe66a408668ac16a4d2f422c085ca3cd22 100644 (file)
@@ -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 () != nullptr
              && b->name () != nullptr
              && streq (a->name (), b->name ())));
@@ -5236,7 +5236,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 ());
 
@@ -5355,8 +5355,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:
@@ -5374,7 +5374,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.  */
index 3917b40e3660810df362a9172817bc2c919fe4f1..2058f2c8bb94ae9d09a20ae65c48d570adac5e63 100644 (file)
@@ -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 ())