From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 998493858D28; Tue, 2 Apr 2024 19:52:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 998493858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712087549; bh=8Gh0q4tlTG+/NRYJZdQ/AkKOYYviunKKjJ09kCZ9l80=; h=From:To:Subject:Date:From; b=MEN3Z6xK1NBoLr7wUbcpdByYGoc8bBEC8nhxwopff4Mzc8FypI7ZU9ciUz9TTf/ML 8n9XBoc4oB6PEWZRBA08X39ksY/juW/OTVmos+013DefE4ldYR7Gau/+lE6f4kAE2r gLmkS6mcx9fbi004v5shASngf0Wbrzo7NJedrPRs= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Tom Tromey To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9760] libiberty: Invoke D demangler when --format=auto X-Act-Checkin: gcc X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 2f2924078ce51c2a0da3ad8f958f2d1de533969a X-Git-Newrev: ca2f7c84927f85b95f0f48f82b93f1460c372db4 Message-Id: <20240402195229.998493858D28@sourceware.org> Date: Tue, 2 Apr 2024 19:52:29 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ca2f7c84927f85b95f0f48f82b93f1460c372db4 commit r14-9760-gca2f7c84927f85b95f0f48f82b93f1460c372db4 Author: Tom Tromey Date: Sat Mar 30 13:48:30 2024 -0600 libiberty: Invoke D demangler when --format=auto Investigating GDB PR d/31580 showed that the libiberty demangler doesn't automatically demangle D mangled names. However, I think it should -- like C++ and Rust (new-style), D mangled names are readily distinguished by the leading "_D", and so the likelihood of confusion is low. The other non-"auto" cases in this code are Ada (where the encoded form could more easily be confused by ordinary programs) and Java (which is long gone, but which also shared the C++ mangling and thus was just an output style preference). This patch also fixed another GDB bug, though of course that part won't apply to the GCC repository. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31580 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30276 libiberty * cplus-dem.c (cplus_demangle): Try the D demangler with "auto" format. * testsuite/d-demangle-expected: Add --format=auto test. Diff: --- libiberty/cplus-dem.c | 2 +- libiberty/testsuite/d-demangle-expected | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c index 8b92946981f..ee9e84f5d6b 100644 --- a/libiberty/cplus-dem.c +++ b/libiberty/cplus-dem.c @@ -186,7 +186,7 @@ cplus_demangle (const char *mangled, int options) if (GNAT_DEMANGLING) return ada_demangle (mangled, options); - if (DLANG_DEMANGLING) + if (DLANG_DEMANGLING || AUTO_DEMANGLING) { ret = dlang_demangle (mangled, options); if (ret) diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected index 47b059c4298..cfbdf2a52cb 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -1470,3 +1470,8 @@ demangle.anonymous --format=dlang _D8demangle9anonymous03fooZ demangle.anonymous.foo +# +# Test that 'auto' works. +--format=auto +_D8demangle9anonymous03fooZ +demangle.anonymous.foo