From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [pushed] gdb: change noerr parameter of lookup_typename to bool
Date: Fri, 23 Oct 2026 00:01:49 -0400 [thread overview]
Message-ID: <20261023040151.940137-1-simon.marchi@efficios.com> (raw)
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<gdb::byte_vector> 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
reply other threads:[~2026-10-23 4:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261023040151.940137-1-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox