]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove smash_to_memberptr_type
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 17 Dec 2025 15:55:01 +0000 (10:55 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 6 Jan 2026 19:59:16 +0000 (14:59 -0500)
smash_to_memberptr_type is only used by lookup_memberptr_type, remove it
and inline its code there.

Change-Id: I8bc1b8da38f1124e231451aed183d957ea1c37af
Approved-By: Tom Tromey <tom@tromey.com>
gdb/gdbtypes.c
gdb/gdbtypes.h

index 4d961e7a6ce0f8f8bf1b753a56525e430b8525c6..75404d00e1ac78cf10600993608e2f60d9c0b34a 100644 (file)
@@ -751,18 +751,21 @@ replace_type (struct type *ntype, struct type *type)
   gdb_assert (ntype->instance_flags () == type->instance_flags ());
 }
 
-/* Implement direct support for MEMBER_TYPE in GNU C++.
-   May need to construct such a type if this is the first use.
-   The TYPE is the type of the member.  The DOMAIN is the type
-   of the aggregate that the member belongs to.  */
+/* See gdbtypes.h.  */
 
-struct type *
-lookup_memberptr_type (struct type *type, struct type *domain)
+type *
+lookup_memberptr_type (type *to_type, type *domain)
 {
-  struct type *mtype;
+  type *mtype = type_allocator (to_type).new_type ();
+
+  mtype->set_code (TYPE_CODE_MEMBERPTR);
+  mtype->set_target_type (to_type);
+  set_type_self_type (mtype, domain);
+
+  /* Assume that a data member pointer is the same size as a normal
+     pointer.  */
+  mtype->set_length (gdbarch_ptr_bit (to_type->arch ()) / TARGET_CHAR_BIT);
 
-  mtype = type_allocator (type).new_type ();
-  smash_to_memberptr_type (mtype, domain, type);
   return mtype;
 }
 
@@ -1443,30 +1446,6 @@ set_type_self_type (struct type *type, struct type *self_type)
     }
 }
 
-/* Smash TYPE to be a type of pointers to members of SELF_TYPE with type
-   TO_TYPE.  A member pointer is a weird thing -- it amounts to a
-   typed offset into a struct, e.g. "an int at offset 8".  A MEMBER
-   TYPE doesn't include the offset (that's the value of the MEMBER
-   itself), but does include the structure type into which it points
-   (for some reason).
-
-   When "smashing" the type, we preserve the objfile that the old type
-   pointed to, since we aren't changing where the type is actually
-   allocated.  */
-
-void
-smash_to_memberptr_type (struct type *type, struct type *self_type,
-                        struct type *to_type)
-{
-  smash_type (type);
-  type->set_code (TYPE_CODE_MEMBERPTR);
-  type->set_target_type (to_type);
-  set_type_self_type (type, self_type);
-  /* Assume that a data member pointer is the same size as a normal
-     pointer.  */
-  type->set_length (gdbarch_ptr_bit (to_type->arch ()) / TARGET_CHAR_BIT);
-}
-
 /* Smash TYPE to be a type of pointer to methods type TO_TYPE.
 
    When "smashing" the type, we preserve the objfile that the old type
index 232329b2a6d96c93c629b0659f71eac5cc41497a..8ba314eb663979a8f390a9a1f83592d9a53e52a9 100644 (file)
@@ -2462,7 +2462,11 @@ extern const char *address_space_type_instance_flags_to_name
 extern struct type *make_type_with_address_space
   (struct type *type, type_instance_flags space_identifier);
 
-extern struct type *lookup_memberptr_type (struct type *, struct type *);
+/* Implement direct support for MEMBER_TYPE in GNU C++.
+   TO_TYPE is the type of the member.  DOMAIN is the type of the aggregate that
+   the member belongs to.  */
+
+extern type *lookup_memberptr_type (type *to_type, type *domain);
 
 extern struct type *lookup_methodptr_type (struct type *);
 
@@ -2471,9 +2475,6 @@ extern void smash_to_method_type (struct type *type, struct type *self_type,
                                  gdb::array_view<struct field> args,
                                  int varargs);
 
-extern void smash_to_memberptr_type (struct type *, struct type *,
-                                    struct type *);
-
 extern void smash_to_methodptr_type (struct type *, struct type *);
 
 extern const char *type_name_or_error (struct type *type);