From patchwork Wed Dec 17 15:54:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 126711 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id B7A354BA2E3E for ; Wed, 17 Dec 2025 15:56:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7A354BA2E3E X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 755544BA2E2C for ; Wed, 17 Dec 2025 15:55:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 755544BA2E2C Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 755544BA2E2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986955; cv=none; b=l0qINiVnyQ+G2JpW3XD78RmRPXXDQK8sO0oeaKjQ8sRxYOGkJbLOjJdmJbXIkdpJ/KHorf10lmwz95Jzgrjp3ojnsl15qfoiqkt1PDHOVmz58sf52T+VWw/0VtmDkCHeeXv1AWDvMPBd0l5WTlKRoDZ2B9vjjOD+QKvgGTn52XA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986955; c=relaxed/simple; bh=fYHpbpdE+9rpMjaDML0J6fYCpP8CMDz8ql0Bq/IIW+U=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=HmZTGVGMzfcw3ExR0TXu5bytiFj1Htp07R/bgUZBe7DpINDh4Mp0p/qqFMlbdeJMOCMJXYTiKYkcXrzFOC/9Y01iNmDZ6rrPNSoTq92MQfnAuyBN2SwBtz/fV8LOMMWlgwVK1F8lU9bJJrCs9ZV3AY34vVG/Ak2XcLtbG3hXr5M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 755544BA2E2C Received: by simark.ca (Postfix) id 0F4A51E0B6; Wed, 17 Dec 2025 10:55:55 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 3/7] gdb: remove make_reference_type typeptr parameter Date: Wed, 17 Dec 2025 10:54:57 -0500 Message-ID: <20251217155550.37654-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217155550.37654-1-simon.marchi@efficios.com> References: <20251217155550.37654-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1166.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, LOCAL_AUTHENTICATION_FAIL_DMARC, LOCAL_AUTHENTICATION_FAIL_SPF, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org From: Simon Marchi It is always passed nullptr. Change-Id: I1ec2afacb694c6d708df28ea6d47f08ceaf973db --- gdb/gdbtypes.c | 39 ++++++--------------------------------- gdb/gdbtypes.h | 5 +++-- 2 files changed, 9 insertions(+), 35 deletions(-) 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 **);