summaryrefslogtreecommitdiff
path: root/libiberty/d-demangle.c
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/d-demangle.c
parent34f3e0657a1fa976d989b22d18b3b2adf6ddd59b (diff)
downloadgcc-392e141079a198c93b19bfcd1fe2bd5df456c999.tar.gz
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/d-demangle.c')
-rw-r--r--libiberty/d-demangle.c19
1 files changed, 19 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)
&& (mangled[2] == 'T' || mangled[2] == 'U'))
return dlang_parse_template (decl, mangled, info, len);
+ /* There can be multiple different 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. */
+ if (len >= 4 && mangled[0] == '_' && mangled[1] == '_' && mangled[2] == 'S')
+ {
+ const char *numptr = mangled + 3;
+ while (numptr < (mangled + len) && ISDIGIT (*numptr))
+ numptr++;
+
+ if (mangled + len == numptr)
+ {
+ /* Skip over the fake parent. */
+ mangled += len;
+ return dlang_identifier (decl, mangled, info);
+ }
+
+ /* else demangle it as a plain identifier. */
+ }
+
return dlang_lname (decl, mangled, len);
}