[binutils-gdb] gdb: add default parameter for cp_demangled_name_to_comp errmsg
Simon Marchi via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=15de21830818130cd35b1e698d20c6b817cbb66a commit 15de21830818130cd35b1e698d20c6b817cbb66a Author: Simon Marchi <[email protected]> Date: Thu Aug 20 14:02:33 2026 -0400 gdb: add default parameter for cp_demangled_name_to_comp errmsg 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 Approved-By: Tom Tromey <[email protected]> Diff: --- 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 4be50599762..aee5d834151 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 335e06a039f..36d7c8dd113 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 2bd3430a7a8..e495895afdb 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. */