[3/7] gdb: remove make_reference_type typeptr parameter

Message ID 20251217155550.37654-4-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 passed nullptr.

Change-Id: I1ec2afacb694c6d708df28ea6d47f08ceaf973db
---
 gdb/gdbtypes.c | 39 ++++++---------------------------------
 gdb/gdbtypes.h |  5 +++--
 2 files changed, 9 insertions(+), 35 deletions(-)
  

Patch

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 2b0025c05c42..aa0cb2c515a3 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -407,15 +407,10 @@  lookup_pointer_type (struct type *type)
   return make_pointer_type (type);
 }
 
-/* Lookup a C++ `reference' to a type TYPE.  TYPEPTR, if nonzero,
-   points to a pointer to memory where the reference type should be
-   stored.  If *TYPEPTR is zero, update it to point to the reference
-   type we return.  We allocate new memory if needed. REFCODE denotes
-   the kind of reference type to lookup (lvalue or rvalue reference).  */
+/* See gdbtypes.h.  */
 
-struct type *
-make_reference_type (struct type *type, struct type **typeptr,
-		      enum type_code refcode)
+type *
+make_reference_type (type *type, type_code refcode)
 {
   struct type *ntype;	/* New type */
   struct type **reftype;
@@ -427,31 +422,9 @@  make_reference_type (struct type *type, struct type **typeptr,
 	   : TYPE_RVALUE_REFERENCE_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);
   reftype = (refcode == TYPE_CODE_REF ? &TYPE_REFERENCE_TYPE (type)
 	     : &TYPE_RVALUE_REFERENCE_TYPE (type));
@@ -484,7 +457,7 @@  make_reference_type (struct type *type, struct type **typeptr,
 struct type *
 lookup_reference_type (struct type *type, enum type_code refcode)
 {
-  return make_reference_type (type, (struct type **) 0, refcode);
+  return make_reference_type (type, refcode);
 }
 
 /* Lookup the lvalue reference type for the type TYPE.  */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index f27ff36498c0..afb8319cca6b 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2432,9 +2432,10 @@  extern struct type *lookup_reference_type (struct type *, enum type_code);
 extern struct type *lookup_lvalue_reference_type (struct type *);
 extern struct type *lookup_rvalue_reference_type (struct type *);
 
+/* Lookup a C++ `reference' to a type TYPE.  REFCODE denotes the kind of
+   reference type to lookup (lvalue or rvalue reference).  */
 
-extern struct type *make_reference_type (struct type *, struct type **,
-					 enum type_code);
+extern type *make_reference_type (type *type, type_code refcode);
 
 extern struct type *make_cv_type (int, int, struct type *, struct type **);