From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id idR1N6OZm2od4SsAWB0awg (envelope-from ) for ; Sat, 05 Sep 2026 00:25:07 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=s4YdmcKe; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DE5BF1E09E; Sat, 05 Sep 2026 00:25:07 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 173621E091 for ; Sat, 05 Sep 2026 00:25:07 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92C084BAE7EB for ; Sat, 5 Sep 2026 04:25:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92C084BAE7EB Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=s4YdmcKe Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 93EC04BB58DF for ; Sat, 5 Sep 2026 04:24:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93EC04BB58DF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 93EC04BB58DF Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788582244; cv=none; b=JqeAhrNujr5R3oE3DNJx7TRVpCmgqxNo/aA9chGs1uwOLk4PkfQIg3VSWiEyJH8ufbmJYZBhOv7/HaZz012/ud6E+4OJrQSj0rEqJCrTNZx0jZw5pZMq71gHmsoZQJgRMMzdzQOVOS9UdcvM4g0aqYWCriuysigaSPP83kZZ2uc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788582244; c=relaxed/simple; bh=l72+HyhzWgAThoICcQv7iQd0cF5hjR3R1sCApWB74vM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=d0LxHkHZAk3TRIT6u4ugcPvTfnqrWj+TtiHsgCGL54q91gDtgbFW/jPgYNnlXaABAB698kTW3RJBLHuRNyWOSI+JdsQMbrF5QxysuxNp+Z/rFyoBqR4VNUVSzCfrxeE+BcNDmte5FEI5mlGEToLXXpNT0eIq6y1jVNjcge2LXSA= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=s4YdmcKe DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93EC04BB58DF Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 6854NvhJ081221 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 5 Sep 2026 00:24:02 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 6854NvhJ081221 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1788582243; bh=pTgiHye54sKsorxu5iUAj8xc+AbR5dcUq6RaUYTs5fo=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=s4YdmcKe3x5xhdZhaNAKDZydaIJhoGc/2recjq7hVlwKi9oQvXPOkxstF509jhCs0 O7XlCKwt0K9wz3N1tkfT7LpZZvpjR8V/1CETLCStv7yMWoMkoPoWT6nvCb3msh2KZM YMgBXDAaSuIyBtMC8IE/790uCyeQ1jlTlq6oKWxYLFPBbZ4dW/LG7Sg4ptWe8hHToZ YwxTQSzXQTCNcCgc0tQxFwPmmGNT1zT/Z801g8N7I4r+JaZTnilfi1svQeTRCCQQfb SsSpdIIzwelqfPNhZQPJxFF8R8rlJxVf5qUq5//oF0uM38CES0R6HX0p1UGw48BmjL 8qK+elGZD1ACw== Received: by simark.ca (Postfix) id 800291E09E; Sat, 05 Sep 2026 00:23:56 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 02/19] gdb: replace parse_type macros with functions Date: Sat, 5 Sep 2026 00:23:05 -0400 Message-ID: <20260905042353.1702204-3-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260905042353.1702204-1-simon.marchi@polymtl.ca> References: <20260905042353.1702204-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 5 Sep 2026 04:23:57 +0000 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~public-inbox=simark.ca@sourceware.org From: Simon Marchi I noticed that many parsers defined the same parse_type macro, so I thought let's move it to parser-defs.h so it can be shared. And while at it, change it to a static inline function, as well as the other macros (the language-specific ones). Change-Id: I39160263f2ce63fdaddebf9f0b61ccaf94773e1d --- gdb/ada-exp.y | 2 -- gdb/c-exp.y | 2 -- gdb/d-exp.y | 11 ++++++++--- gdb/f-exp.y | 11 ++++++++--- gdb/go-exp.y | 2 -- gdb/m2-exp.y | 11 ++++++++--- gdb/p-exp.y | 2 -- gdb/parser-defs.h | 8 ++++++++ 8 files changed, 32 insertions(+), 17 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 15f64fdf01f9..7fd0e6d7c7db 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -46,8 +46,6 @@ #include "ada-exp.h" #include "cli/cli-style.h" -#define parse_type(ps) builtin_type (ps->gdbarch ()) - /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc). */ #define GDB_YY_REMAP_PREFIX ada_ diff --git a/gdb/c-exp.y b/gdb/c-exp.y index e6a82e2aa3cc..d58bce833551 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -54,8 +54,6 @@ #include "macroexp.h" #include "cli/cli-style.h" -#define parse_type(ps) builtin_type (ps->gdbarch ()) - /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc). */ #define GDB_YY_REMAP_PREFIX c_ diff --git a/gdb/d-exp.y b/gdb/d-exp.y index 1031eb1eccac..d3263ba4fd72 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -50,9 +50,6 @@ #include "expop.h" #include "cli/cli-style.h" -#define parse_type(ps) builtin_type (ps->gdbarch ()) -#define parse_d_type(ps) builtin_d_type (ps->gdbarch ()) - /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc). */ #define GDB_YY_REMAP_PREFIX d_ @@ -74,6 +71,14 @@ static void yyerror (const char *); static int type_aggregate_p (struct type *); +/* Return the D type table for the architecture associated to PS. */ + +static inline const struct builtin_d_type * +parse_d_type (parser_state *ps) +{ + return builtin_d_type (ps->gdbarch ()); +} + using namespace expr; %} diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 4216112c10b7..4cdfcc973923 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -52,9 +52,6 @@ #include "type-stack.h" #include "f-exp.h" -#define parse_type(ps) builtin_type (ps->gdbarch ()) -#define parse_f_type(ps) builtin_f_type (ps->gdbarch ()) - /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc). */ #define GDB_YY_REMAP_PREFIX f_ @@ -97,6 +94,14 @@ static void fortran_wrap2_kind (type *base_type); template static void fortran_wrap3_kind (type *base_type); +/* Return the Fortran type table for the architecture associated to PS. */ + +static inline const struct builtin_f_type * +parse_f_type (parser_state *ps) +{ + return builtin_f_type (ps->gdbarch ()); +} + using namespace expr; %} diff --git a/gdb/go-exp.y b/gdb/go-exp.y index 289fd81db857..199da6dc5c37 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -61,8 +61,6 @@ #include "block.h" #include "expop.h" -#define parse_type(ps) builtin_type (ps->gdbarch ()) - /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc). */ #define GDB_YY_REMAP_PREFIX go_ diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index 97e833ddf6ef..0889054f1f37 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -45,9 +45,6 @@ #include "block.h" #include "m2-exp.h" -#define parse_type(ps) builtin_type (ps->gdbarch ()) -#define parse_m2_type(ps) builtin_m2_type (ps->gdbarch ()) - /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc). */ #define GDB_YY_REMAP_PREFIX m2_ @@ -69,6 +66,14 @@ static int parse_number (int); /* The sign of the number being parsed. */ static int number_sign = 1; +/* Return the Modula-2 type table for the architecture associated to PS. */ + +static inline const struct builtin_m2_type * +parse_m2_type (parser_state *ps) +{ + return builtin_m2_type (ps->gdbarch ()); +} + using namespace expr; %} diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 1a43837ae333..70c74beae438 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -51,8 +51,6 @@ #include "block.h" #include "expop.h" -#define parse_type(ps) builtin_type (ps->gdbarch ()) - /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc). */ #define GDB_YY_REMAP_PREFIX pascal_ diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index cfa9d9c111da..7e4f438e6f08 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -329,6 +329,14 @@ struct parser_state : public expr_builder std::vector m_operations; }; +/* Return the type table for the architecture associated to PS. */ + +static inline const struct builtin_type * +parse_type (parser_state *ps) +{ + return builtin_type (ps->gdbarch ()); +} + /* A string token, either a char-string or bit-string. Char-strings are used, for example, for the names of symbols. */ -- 2.55.0