summaryrefslogtreecommitdiffstats
path: root/libiberty
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-08-29 20:26:06 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2021-08-30 01:14:18 +0200
commit392e141079a198c93b19bfcd1fe2bd5df456c999 (patch)
tree7a7790433e9748898047357b4ea5c74fbf680e2a /libiberty
parentlibiberty: Add support for demangling D function literals as template value p... (diff)
downloadgcc-392e141079a198c93b19bfcd1fe2bd5df456c999.tar.gz
gcc-392e141079a198c93b19bfcd1fe2bd5df456c999.tar.bz2
gcc-392e141079a198c93b19bfcd1fe2bd5df456c999.tar.xz
libiberty: Add support for demangling local D template declarations
The D language now allows multiple different template declarations in the same function that have the same mangled name. To make the mangled names unique, a fake parent in the form `__Sddd' is added to the symbol. This information is not important for the user, so the demangler now handles and ignores it. libiberty/ChangeLog: * d-demangle.c (dlang_identifier): Skip over fake parent manglings. * testsuite/d-demangle-expected: Add tests.
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/d-demangle.c19
-rw-r--r--libiberty/testsuite/d-demangle-expected24
2 files changed, 43 insertions, 0 deletions
diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index d74cf47b1a9..a2152cc6551 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -1044,6 +1044,25 @@ dlang_identifier (string *decl, const char *mangled, struct dlang_info *info)
1044 && (mangled[2] == 'T' || mangled[2] == 'U')) 1044 && (mangled[2] == 'T' || mangled[2] == 'U'))
1045 return dlang_parse_template (decl, mangled, info, len); 1045 return dlang_parse_template (decl, mangled, info, len);
1046 1046
1047 /* There can be multiple different declarations in the same function that have
1048 the same mangled name. To make the mangled names unique, a fake parent in
1049 the form `__Sddd' is added to the symbol. */
1050 if (len >= 4 && mangled[0] == '_' && mangled[1] == '_' && mangled[2] == 'S')
1051 {
1052 const char *numptr = mangled + 3;
1053 while (numptr < (mangled + len) && ISDIGIT (*numptr))
1054 numptr++;
1055
1056 if (mangled + len == numptr)
1057 {
1058 /* Skip over the fake parent. */
1059 mangled += len;
1060 return dlang_identifier (decl, mangled, info);
1061 }
1062
1063 /* else demangle it as a plain identifier. */
1064 }
1065
1047 return dlang_lname (decl, mangled, len); 1066 return dlang_lname (decl, mangled, len);
1048} 1067}
1049 1068
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 87ed8d330a8..c35185c3e1e 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -1420,5 +1420,29 @@ _D3std3uni__T6toCaseS_DQvQt12toLowerIndexFNaNbNiNewZtVii1043S_DQCjQCi10toLowerTa
1420std.uni.toCase!(std.uni.toLowerIndex(dchar), 1043, std.uni.toLowerTab(ulong), std.ascii.toLower, immutable(char)[]).toCase(immutable(char)[]).__foreachbody2(ref ulong, ref dchar).__foreachbody3(ref dchar) 1420std.uni.toCase!(std.uni.toLowerIndex(dchar), 1043, std.uni.toLowerTab(ulong), std.ascii.toLower, immutable(char)[]).toCase(immutable(char)[]).__foreachbody2(ref ulong, ref dchar).__foreachbody3(ref dchar)
1421# 1421#
1422--format=dlang 1422--format=dlang
1423_D8demangle4mainFZ1xi
1424demangle.main().x
1425#
1426--format=dlang
1427_D8demangle4mainFZ4__S11xi
1428demangle.main().x
1429#
1430--format=dlang
1431_D8demangle4mainFZ1fMFNaNbNiNfZv
1432demangle.main().f()
1433#
1434--format=dlang
1435_D8demangle4mainFZ4__S11fMFNaNbNiNfZv
1436demangle.main().f()
1437#
1438--format=dlang
1439_D3mod4funcFZ__T6nestedTiZQkMFNaNbNiNfZi
1440mod.func().nested!(int).nested()
1441#
1442--format=dlang
1443_D3mod4funcFZ__T6nestedTiZ4__S1QpMFNaNbNiNfZi
1444mod.func().nested!(int).nested()
1445#
1446--format=dlang
1423_D6mangle__T8fun21753VSQv6S21753S1f_DQBj10__lambda71MFNaNbNiNfZvZQCbQp 1447_D6mangle__T8fun21753VSQv6S21753S1f_DQBj10__lambda71MFNaNbNiNfZvZQCbQp
1424mangle.fun21753!(mangle.S21753(mangle.__lambda71())).fun21753 1448mangle.fun21753!(mangle.S21753(mangle.__lambda71())).fun21753