From patchwork Wed Dec 17 15:54:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 126708 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 C74024BA2E1F for ; Wed, 17 Dec 2025 15:56:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C74024BA2E1F 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 443DB4BA2E34 for ; Wed, 17 Dec 2025 15:55:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 443DB4BA2E34 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 443DB4BA2E34 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=1765986956; cv=none; b=aEsnh0E2E4EP35S7aInfqORJGYyE2BcX4dGHFKYmjtunFKbKkhU8qLrgMzIUKt4vozjiMlcoaovEqvqycojyS8gqgh6F8+k1M4j3ZwXa40ESbfYtvmL+p4rT7zd9WZiQxhMeLOTWGUP/gDFnbhhUWnINsGevzKpquoSqqy08g5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986956; c=relaxed/simple; bh=LQzjjz7BO6LRclkNcJyWa41BK/oLTJhexOneS07oKVo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=hs+0O4KzsmTvQd9yRAl6lhXCeSQYuMv+i3uBjLmUfsLsC/WC0ang/3zPmryO/ttfTnjh2q4NDQ+M2cad3jEBdKtAH35swwnETDaHsByFOPnGqYbiA75E9vh89xS5UasrOFBd/H+R+uf7xD4hc2IxdVfcffRP7THvofgM1jr3lxc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 443DB4BA2E34 Received: by simark.ca (Postfix) id CE3D71E0C2; Wed, 17 Dec 2025 10:55:55 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 5/7] gdb: remove make_function_type Date: Wed, 17 Dec 2025 10:54:59 -0500 Message-ID: <20251217155550.37654-6-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_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 We now have make_function_type and lookup_function_type exposed by gdbtypes.h, which do essentially the same thing. Remove make_function_type, inlining its code inside create_function_type. Change all other callers of make_function_type to use lookup_function_type instead. Change-Id: Id7c25f02059efe5c0f15e8ab8a35ac1fa97d9d6a --- gdb/avr-tdep.c | 2 +- gdb/ft32-tdep.c | 2 +- gdb/gdbtypes.c | 24 +++++++----------------- gdb/gdbtypes.h | 4 ---- gdb/z80-tdep.c | 2 +- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 1a80e0b4ef8b..a88fdb2f9202 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1475,7 +1475,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) be defined. */ type_allocator alloc (gdbarch); tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - tdep->func_void_type = make_function_type (tdep->void_type); + tdep->func_void_type = lookup_function_type (tdep->void_type); tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL, tdep->func_void_type); diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 1f2c2d970afa..ecfbdfd0fc57 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -576,7 +576,7 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) be defined. */ type_allocator alloc (gdbarch); void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - func_void_type = make_function_type (void_type); + func_void_type = lookup_function_type (void_type); tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL, func_void_type); tdep->pc_type->set_instance_flags (tdep->pc_type->instance_flags () diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f42fee408fdb..d3e9bbbdcd52 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -476,22 +476,6 @@ lookup_rvalue_reference_type (struct type *type) return lookup_reference_type (type, TYPE_CODE_RVALUE_REF); } -/* See gdbtypes.h. */ - -type * -make_function_type (type *return_type) -{ - type *ntype = type_allocator (return_type).new_type (); - - ntype->set_target_type (return_type); - ntype->set_length (1); - ntype->set_code (TYPE_CODE_FUNC); - - INIT_FUNC_SPECIFIC (ntype); - - return ntype; -} - /* Given a return type and argument types, create new function type. If the final type in PARAM_TYPES is NULL, create a varargs function. New type is allocated using ALLOC. */ @@ -499,7 +483,13 @@ make_function_type (type *return_type) static type * create_function_type (type *return_type, int nparams, type **param_types) { - type *fn = make_function_type (return_type); + type *fn = type_allocator (return_type).new_type (); + + fn->set_target_type (return_type); + fn->set_length (1); + fn->set_code (TYPE_CODE_FUNC); + + INIT_FUNC_SPECIFIC (fn); if (nparams > 0) { diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index b467190ffb7f..486d62244f6c 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2518,10 +2518,6 @@ extern type *make_pointer_type (type *type); extern struct type *lookup_pointer_type (struct type *); -/* Lookup a function type that returns type RETURN_TYPE. */ - -extern struct type *make_function_type (type *return_type); - /* Create a new function type with return type RETURN_TYPE and unspecified number and types of parameters. diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index fd4171abac76..3b45c455a8a8 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -1142,7 +1142,7 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) type_allocator alloc (gdbarch); tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - tdep->func_void_type = make_function_type (tdep->void_type); + tdep->func_void_type = lookup_function_type (tdep->void_type); tdep->pc_type = init_pointer_type (alloc, tdep->addr_length * TARGET_CHAR_BIT, NULL, tdep->func_void_type);