From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eYxEDGBBh2q8nzIAWB0awg (envelope-from ) for ; Thu, 20 Aug 2026 14:03:12 -0400 Received: by simark.ca (Postfix, from userid 112) id 2C2AE1E033; Thu, 20 Aug 2026 14:03:12 -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 [38.145.34.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 A8A931E033 for ; Thu, 20 Aug 2026 14:03:10 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35DC44BB1C2A for ; Thu, 20 Aug 2026 18:03:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35DC44BB1C2A Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 6E6724B9DB65 for ; Thu, 20 Aug 2026 18:02:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E6724B9DB65 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 6E6724B9DB65 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=1787248966; cv=none; b=cosAzSNxebJStESuiZ8FiiZoqKP2RS5o1yDO/4EJQ/hje5UPdivmuDmf9H/QxFTeIjiP+tR1FZAXYD32wNQijawXthBlchrJdWlVKkb02PyfWB/pptdKVZ1lJiWunWzJ5FgyXo1GgONNCAlJdQF/fL0KNmQQdv7f24u8w624fkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787248966; c=relaxed/simple; bh=7eZZlZeDomM/PvnuOuqmdYCt7Ck1OrtSVpz+zXtLKNE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ibCcn9PHR0Jhj59FBJwPb5bNWd5Qu7vFcOZiRN3EUHx03s2BbF/257rd55xbPremLSbzeVyTnlCPN0Y2i8GH9m/9LHAKWUqAC7F3fryzBXp0KWC1MxdE78HyywXUUPdzOkY7JyyTgH3K3hjQ9QAxd3GZvupP8RdGabmgHJ6//bY= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E6724B9DB65 Received: by simark.ca (Postfix) id A7C931E033; Thu, 20 Aug 2026 14:02:44 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] gdb: add default parameter for cp_demangled_name_to_comp errmsg Date: Thu, 20 Aug 2026 14:02:33 -0400 Message-ID: <20260820180243.730651-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.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 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 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 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 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 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