From: Simon Marchi Date: Wed, 17 Dec 2025 15:55:01 +0000 (-0500) Subject: gdb: remove smash_to_memberptr_type X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f0ba520b3c2c70be4c4d88ead3bb4ea74c57858;p=thirdparty%2Fbinutils-gdb.git gdb: remove smash_to_memberptr_type 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 --- diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 4d961e7a6ce..75404d00e1a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -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 diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 232329b2a6d..8ba314eb663 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -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 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);