[2/7] gdb: remove make_pointer_type typeptr parameter

Message ID 20251217155550.37654-3-simon.marchi@efficios.com
State New
Headers
Series gdbtypes cleanups |

Commit Message

Simon Marchi Dec. 17, 2025, 3:54 p.m. UTC
  From: Simon Marchi <simon.marchi@polymtl.ca>

It is always nullptr.

Change-Id: I88e81427c781bd6356203ccc969eae1ab84ac0ef
---
 gdb/break-catch-throw.c |  2 +-
 gdb/gdbtypes.c          | 37 ++++++-------------------------------
 gdb/gdbtypes.h          |  4 +++-
 gdb/gnu-v3-abi.c        |  4 ++--
 gdb/mdebugread.c        |  2 +-
 5 files changed, 13 insertions(+), 36 deletions(-)
  

Patch

diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 3ad3beb41e8b..552d7124bbd9 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -481,7 +481,7 @@  compute_exception (struct gdbarch *argc, struct internalvar *var, void *ignore)
      the std::type_info for the exception.  Now we find the type from
      the type_info and cast the result.  */
   obj_type = cplus_type_from_type_info (arg1);
-  return value_ind (value_cast (make_pointer_type (obj_type, NULL), arg0));
+  return value_ind (value_cast (make_pointer_type (obj_type), arg0));
 }
 
 /* Implementation of the '$_exception' variable.  */
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 96d5e0c425a6..2b0025c05c42 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -360,13 +360,10 @@  smash_type (struct type *type)
   /* For now, leave the pointer/reference types alone.  */
 }
 
-/* Lookup a pointer to a type TYPE.  TYPEPTR, if nonzero, points
-   to a pointer to memory where the pointer type should be stored.
-   If *TYPEPTR is zero, update it to point to the pointer type we return.
-   We allocate new memory if needed.  */
+/* See gdbtypes.h.  */
 
-struct type *
-make_pointer_type (struct type *type, struct type **typeptr)
+type *
+make_pointer_type (type *type)
 {
   struct type *ntype;	/* New type */
   struct type *chain;
@@ -374,31 +371,9 @@  make_pointer_type (struct type *type, struct type **typeptr)
   ntype = TYPE_POINTER_TYPE (type);
 
   if (ntype)
-    {
-      if (typeptr == 0)
-	return ntype;		/* Don't care about alloc,
-				   and have new type.  */
-      else if (*typeptr == 0)
-	{
-	  *typeptr = ntype;	/* Tracking alloc, and have new type.  */
-	  return ntype;
-	}
-    }
-
-  if (typeptr == 0 || *typeptr == 0)	/* We'll need to allocate one.  */
-    {
-      ntype = type_allocator (type).new_type ();
-      if (typeptr)
-	*typeptr = ntype;
-    }
-  else			/* We have storage, but need to reset it.  */
-    {
-      ntype = *typeptr;
-      chain = TYPE_CHAIN (ntype);
-      smash_type (ntype);
-      TYPE_CHAIN (ntype) = chain;
-    }
+    return ntype;
 
+  ntype = type_allocator (type).new_type ();
   ntype->set_target_type (type);
   TYPE_POINTER_TYPE (type) = ntype;
 
@@ -429,7 +404,7 @@  make_pointer_type (struct type *type, struct type **typeptr)
 struct type *
 lookup_pointer_type (struct type *type)
 {
-  return make_pointer_type (type, (struct type **) 0);
+  return make_pointer_type (type);
 }
 
 /* Lookup a C++ `reference' to a type TYPE.  TYPEPTR, if nonzero,
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index ebacb30b847e..f27ff36498c0 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2511,7 +2511,9 @@  extern struct_elt lookup_struct_elt (struct type *, const char *, int);
 
 extern struct type *lookup_struct_elt_type (struct type *, const char *, int);
 
-extern struct type *make_pointer_type (struct type *, struct type **);
+/* Lookup a pointer to a type TYPE.  */
+
+extern type *make_pointer_type (type *type);
 
 extern struct type *lookup_pointer_type (struct type *);
 
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 700e271903e2..483ae2d98909 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -1003,7 +1003,7 @@  build_std_type_info_type (struct gdbarch *arch)
   struct type *char_type
     = builtin_type (arch)->builtin_char;
   struct type *char_ptr_type
-    = make_pointer_type (make_cv_type (1, 0, char_type, NULL), NULL);
+    = make_pointer_type (make_cv_type (1, 0, char_type, NULL));
 
   t = type_allocator (arch).new_type (TYPE_CODE_STRUCT, 0, nullptr);
 
@@ -1120,7 +1120,7 @@  gnuv3_get_typeid (struct value *value)
 	error (_("cannot find typeinfo for object of type '%s'"),
 	       name);
       typeinfo_value = value_field (vtable, vtable_field_type_info);
-      result = value_ind (value_cast (make_pointer_type (typeinfo_type, NULL),
+      result = value_ind (value_cast (make_pointer_type (typeinfo_type),
 				      typeinfo_value));
     }
   else
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index f5949e614f4b..6f6fddc42831 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -838,7 +838,7 @@  parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 		 "program has no memory available".  To avoid this, we
 		 patch up the type and make it void*
 		 instead. (davidm@azstarnet.com).  */
-	      t = make_pointer_type (t, NULL);
+	      t = make_pointer_type (t);
 	    }
 	}
       b = top_stack->cur_block;