From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cJVkFlrc2mqbXw4AWB0awg (envelope-from ) for ; Fri, 23 Oct 2026 00:02:34 -0400 Received: by simark.ca (Postfix, from userid 112) id 40309378003; Fri, 23 Oct 2026 00:02:34 -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.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 C7DB3378002 for ; Fri, 23 Oct 2026 00:02:26 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 202D54BA23FB for ; Fri, 23 Oct 2026 04:02:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 202D54BA23FB Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id D96224BA2E1B for ; Fri, 23 Oct 2026 04:01:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D96224BA2E1B 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 D96224BA2E1B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792728113; cv=none; b=QP5z2sEGMW8UsU6afIU2k/mH6tRDt69wD8UkcEK81Uul732YjY2da7tKnHD9Vy+uuFGS3s5QNSG8aHM8z23LjlOKWJEySNTgNRi59pwgCJNTOdMhGSgmRniqQCcVpcMkw5Vx+ZoEpOLW1LmAIqnKHOVftAe4e2v5AdTKUDkQRKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792728113; c=relaxed/simple; bh=SARH+AJvty7pDJJ/RZXZUuvPa9dAS7W8fRCoa11QpMo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Gn5QFpoUG5Sl3pzECGwH3e4SrjeyU4Sqf3bO7jy+M2Kv50msjMHLIr6S9vn5oWEgGj+53ZgQXzSsAMGOVaigZQQcU/qyxwNqeHrZ9d917d92uftcJBKyJZj0HKtkSQRx12WC25sAcvnP4O+l11F0SpQSR0EGcdfV2PDFEY5uqDo= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D96224BA2E1B Received: by simark.ca (Postfix) id 0558A378002; Fri, 23 Oct 2026 00:01:51 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [pushed] gdb: change noerr parameter of lookup_typename to bool Date: Fri, 23 Oct 2026 00:01:49 -0400 Message-ID: <20261023040151.940137-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.56.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Change the noerr parameter of lookup_typename to bool, update callers to use true / false. While at it, modernize a bit the body of lookup_typename and do some NULL -> nullptr changes. No functional changes intended. Change-Id: I6c7b251a7db5d90c3d99baff28b5c39327163b7e --- gdb/c-exp-parser.y | 13 ++++--------- gdb/c-lang.c | 6 +++--- gdb/cp-namespace.c | 2 +- gdb/gdbtypes.c | 26 +++++++++++++------------- gdb/gdbtypes.h | 7 +++---- gdb/guile/scm-type.c | 2 +- gdb/m2-exp-parser.c | 4 +++- gdb/m2-exp-parser.y | 2 +- gdb/printcmd.c | 4 ++-- gdb/python/py-type.c | 2 +- gdb/python/py-xmethods.c | 6 ++---- gdb/rust-parse.c | 4 ++-- 12 files changed, 36 insertions(+), 42 deletions(-) diff --git a/gdb/c-exp-parser.y b/gdb/c-exp-parser.y index b24fee0058bf..49b34c009fbe 100644 --- a/gdb/c-exp-parser.y +++ b/gdb/c-exp-parser.y @@ -1344,19 +1344,14 @@ scalar_type: "short"); } | DOUBLE_KEYWORD { $$ = lookup_typename (pstate->language (), - "double", - NULL, - 0); } + "double", nullptr, false); } | FLOAT_KEYWORD { $$ = lookup_typename (pstate->language (), - "float", - NULL, - 0); } + "float", nullptr, false); } | LONG DOUBLE_KEYWORD { $$ = lookup_typename (pstate->language (), - "long double", - NULL, - 0); } + "long double", nullptr, + false); } | UNSIGNED type_name { $$ = lookup_unsigned_typename (pstate->language (), $2.type->name ()); } diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 840320e76cc0..52395ab9d455 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -589,13 +589,13 @@ c_string_operation::evaluate (struct type *expect_type, exp->gdbarch); break; case C_WIDE_STRING: - type = lookup_typename (exp->language_defn, "wchar_t", NULL, 0); + type = lookup_typename (exp->language_defn, "wchar_t", nullptr, false); break; case C_STRING_16: - type = lookup_typename (exp->language_defn, "char16_t", NULL, 0); + type = lookup_typename (exp->language_defn, "char16_t", nullptr, false); break; case C_STRING_32: - type = lookup_typename (exp->language_defn, "char32_t", NULL, 0); + type = lookup_typename (exp->language_defn, "char32_t", nullptr, false); break; default: internal_error (_("unhandled c_string_type")); diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index ce7cba3d2643..39f88e6e4c00 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -609,7 +609,7 @@ cp_lookup_symbol_imports (const char *scope, name_copy.erase (prefix_len); context = lookup_typename (lang, name_copy.c_str (), - parent, 1); + parent, true); } if (context == NULL) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 7bdd2744cf54..f86549aca88d 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1424,25 +1424,24 @@ type_name_or_error (struct type *type) /* See gdbtypes.h. */ -struct type * -lookup_typename (const struct language_defn *language, - const char *name, - const struct block *block, int noerr) +type * +lookup_typename (const language_defn *language, const char *name, + const block *block, bool noerr) { - struct symbol *sym; - - sym = lookup_symbol_in_language (name, block, SEARCH_TYPE_DOMAIN, - language->la_language, NULL).symbol; - if (sym != nullptr) + if (block_symbol bsym + = lookup_symbol_in_language (name, block, SEARCH_TYPE_DOMAIN, + language->la_language, nullptr); + bsym.symbol != nullptr) { - struct type *type = sym->type (); + type *type = bsym.symbol->type (); /* Ensure the length of TYPE is valid. */ check_typedef (type); return type; } if (noerr) - return NULL; + return nullptr; + error (_("No type named %s."), name); } @@ -1455,7 +1454,7 @@ lookup_unsigned_typename (const struct language_defn *language, uns = "unsigned "; uns += name; - return lookup_typename (language, uns.c_str (), NULL, 0); + return lookup_typename (language, uns.c_str (), nullptr, false); } struct type * @@ -1464,7 +1463,8 @@ lookup_signed_typename (const struct language_defn *language, const char *name) /* In C and C++, "char" and "signed char" are distinct types. */ if (streq (name, "char")) name = "signed char"; - return lookup_typename (language, name, NULL, 0); + + return lookup_typename (language, name, nullptr, false); } /* Lookup a structure type named "struct NAME", diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 9650d1463322..2c49b83246c6 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2739,7 +2739,7 @@ extern struct type *check_typedef (struct type *); extern char *gdb_mangle_name (struct type *, int, int); /* Lookup a typedef or primitive type named NAME, visible in lexical block - BLOCK. If NOERR is nonzero, return zero if NAME is not suitably + BLOCK. If NOERR is true, return nullptr if NAME is not suitably defined. If this function finds a suitable type then check_typedef is called on @@ -2747,9 +2747,8 @@ extern char *gdb_mangle_name (struct type *, int, int); then the length of the type will be correct. The original typedef will still be returned, not the result of calling check_typedef. */ -extern struct type *lookup_typename (const struct language_defn *language, - const char *name, - const struct block *block, int noerr); +extern type *lookup_typename (const language_defn *language, const char *name, + const block *block, bool noerr); extern struct type *lookup_template_type (const char *, struct type *, const struct block *); diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 816d6b53c570..6e3216677bd5 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -1248,7 +1248,7 @@ tyscm_lookup_typename (const char *type_name, const struct block *block) type = lookup_enum (type_name + 5, NULL); else type = lookup_typename (current_language, - type_name, block, 0); + type_name, block, false); } catch (const gdb_exception &except) { diff --git a/gdb/m2-exp-parser.c b/gdb/m2-exp-parser.c index a1fff9f58c66..6337fe744cf7 100644 --- a/gdb/m2-exp-parser.c +++ b/gdb/m2-exp-parser.c @@ -400,8 +400,10 @@ m2_yylex (void) SEARCH_VFT, 0).symbol; if (sym && sym->loc_class () == LOC_BLOCK) return BLOCKNAME; + if (lookup_typename (pstate->language (), - tmp.c_str (), pstate->expression_context_block, 1)) + tmp.c_str (), pstate->expression_context_block, true) + != nullptr) return TYPENAME; if(sym) diff --git a/gdb/m2-exp-parser.y b/gdb/m2-exp-parser.y index a10087fa03ab..d14f9aa60be2 100644 --- a/gdb/m2-exp-parser.y +++ b/gdb/m2-exp-parser.y @@ -543,7 +543,7 @@ type = lookup_typename (pstate->language (), copy_name ($1).c_str (), pstate->expression_context_block, - 0); + false); } ; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 09b22ae5010c..60c620e0b4f1 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2528,7 +2528,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format, size_t len; struct gdbarch *gdbarch = value->type ()->arch (); struct type *wctype = lookup_typename (current_language, - "wchar_t", NULL, 0); + "wchar_t", nullptr, false); int wcwidth = wctype->length (); std::optional tem_str; @@ -2820,7 +2820,7 @@ ui_printf (const char *arg, struct ui_file *stream) { struct gdbarch *gdbarch = val_args[i]->type ()->arch (); struct type *wctype = lookup_typename (current_language, - "wchar_t", NULL, 0); + "wchar_t", nullptr, false); struct type *valtype; const gdb_byte *bytes; diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 430373e58118..8b0b90851ea6 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -842,7 +842,7 @@ typy_lookup_typename (const char *type_name, const struct block *block) type = lookup_enum (type_name + 5, block); else type = lookup_typename (current_language, - type_name, block, 0); + type_name, block, false); } catch (const gdb_exception &except) { diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c index 673cf6e07699..bda9071b2169 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -590,10 +590,8 @@ python_xmethod_worker::invoke (struct value *obj, } } else - { - res = value::allocate (lookup_typename (current_language, - "void", NULL, 0)); - } + res = value::allocate (lookup_typename (current_language, "void", nullptr, + false)); return res; } diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index 0c4f2a501abc..0c25008c0dc4 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -458,8 +458,8 @@ rust_parser::rust_lookup_type (const char *name) return result.symbol->type (); } - type = lookup_typename (language (), name, NULL, 1); - if (type != NULL) + type = lookup_typename (language (), name, nullptr, true); + if (type != nullptr) return type; /* Last chance, try a built-in type. */ base-commit: 55ead493f5b0cf43282f20d0ede562e5041e531c -- 2.56.0