From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 1/2] gdb: add default parameter for cp_demangled_name_to_comp errmsg
Date: Thu, 20 Aug 2026 14:02:33 -0400 [thread overview]
Message-ID: <20260820180243.730651-1-simon.marchi@efficios.com> (raw)
Most call sites pass NULL as cp_demangled_name_to_comp's errmsg
parameter (they are not interested in the error message). Make errmsg
have a nullptr default value and simplify those call sites.
I am generally not a big fan of default values, especially when the
parameter changes how the function behaves. But in this case it does
really change the behavior of the function, so I think it's fine.
There is one spot (should_parse) that passed a non-NULL value but then
did not use it, remove that.
Change-Id: I9d30229047d9892cc44953914e6416a607949152
---
gdb/cp-name-parser.y | 3 +--
gdb/cp-support.c | 12 ++++++------
gdb/cp-support.h | 2 +-
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 4be50599762e..aee5d8341519 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -2098,8 +2098,7 @@ should_be_the_same (const char *one, const char *two)
static void
should_parse (const char *name)
{
- std::string err;
- auto parsed = cp_demangled_name_to_comp (name, &err);
+ auto parsed = cp_demangled_name_to_comp (name);
SELF_CHECK (parsed != nullptr);
}
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 335e06a039f2..36d7c8dd113e 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -253,7 +253,7 @@ inspect_type (struct demangle_parse_info *info,
tree will contain pointers into NAME, so NAME cannot
be free'd until all typedef conversion is done and
the final result is converted into a string. */
- i = cp_demangled_name_to_comp (name, NULL);
+ i = cp_demangled_name_to_comp (name);
if (i != NULL)
{
/* Merge the two trees. */
@@ -600,7 +600,7 @@ cp_canonicalize_string_full (const char *string,
std::unique_ptr<demangle_parse_info> info;
estimated_len = strlen (string) * 2;
- info = cp_demangled_name_to_comp (string, NULL);
+ info = cp_demangled_name_to_comp (string);
if (info != NULL)
{
/* Replace all the typedefs in the tree. */
@@ -647,7 +647,7 @@ cp_canonicalize_string (const char *string)
if (cp_already_canonical (string))
return nullptr;
- info = cp_demangled_name_to_comp (string, NULL);
+ info = cp_demangled_name_to_comp (string);
if (info == NULL)
return nullptr;
@@ -709,7 +709,7 @@ mangled_name_to_comp (const char *mangled_name, int options,
/* If we could demangle the name, parse it to build the component
tree. */
std::unique_ptr<demangle_parse_info> info
- = cp_demangled_name_to_comp (demangled_name.get (), NULL);
+ = cp_demangled_name_to_comp (demangled_name.get ());
if (info == NULL)
return NULL;
@@ -904,7 +904,7 @@ cp_func_name (const char *full_name)
struct demangle_component *ret_comp;
std::unique_ptr<demangle_parse_info> info;
- info = cp_demangled_name_to_comp (full_name, NULL);
+ info = cp_demangled_name_to_comp (full_name);
if (!info)
return nullptr;
@@ -933,7 +933,7 @@ cp_remove_params_1 (const char *demangled_name, bool require_params)
if (demangled_name == NULL)
return NULL;
- info = cp_demangled_name_to_comp (demangled_name, NULL);
+ info = cp_demangled_name_to_comp (demangled_name);
if (info == NULL)
return NULL;
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 2bd3430a7a81..e495895afdbc 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -169,7 +169,7 @@ struct type *cp_find_type_baseclass_by_name (struct type *parent_type,
/* Functions from cp-name-parser.y. */
extern std::unique_ptr<demangle_parse_info> cp_demangled_name_to_comp
- (const char *demangled_name, std::string *errmsg);
+ (const char *demangled_name, std::string *errmsg = nullptr);
/* Convert RESULT to a string. ESTIMATED_LEN is used only as a guide
to the length of the result. */
base-commit: d2102b0d6a95ba3b37204976fb3f6ebd935822fb
--
2.55.0
next reply other threads:[~2026-08-20 18:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 18:02 Simon Marchi [this message]
2026-08-20 18:02 ` [PATCH 2/2] gdb: introduce demangle_parse_info_up Simon Marchi
2026-08-21 15:06 ` Tom Tromey
2026-08-21 15:05 ` [PATCH 1/2] gdb: add default parameter for cp_demangled_name_to_comp errmsg Tom Tromey
2026-08-22 5:22 ` Simon Marchi
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=20260820180243.730651-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