Skip to content

Commit ca2f7c8

Browse files
committed
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.
1 parent 2f29240 commit ca2f7c8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

libiberty/cplus-dem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ cplus_demangle (const char *mangled, int options)
186186
if (GNAT_DEMANGLING)
187187
return ada_demangle (mangled, options);
188188

189-
if (DLANG_DEMANGLING)
189+
if (DLANG_DEMANGLING || AUTO_DEMANGLING)
190190
{
191191
ret = dlang_demangle (mangled, options);
192192
if (ret)

libiberty/testsuite/d-demangle-expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,3 +1470,8 @@ demangle.anonymous
14701470
--format=dlang
14711471
_D8demangle9anonymous03fooZ
14721472
demangle.anonymous.foo
1473+
#
1474+
# Test that 'auto' works.
1475+
--format=auto
1476+
_D8demangle9anonymous03fooZ
1477+
demangle.anonymous.foo

0 commit comments

Comments
 (0)