diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-08-29 20:26:06 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-08-30 01:14:18 +0200 |
commit | 392e141079a198c93b19bfcd1fe2bd5df456c999 (patch) | |
tree | 7a7790433e9748898047357b4ea5c74fbf680e2a /libiberty | |
parent | 34f3e0657a1fa976d989b22d18b3b2adf6ddd59b (diff) | |
download | gcc-392e141079a198c93b19bfcd1fe2bd5df456c999.zip gcc-392e141079a198c93b19bfcd1fe2bd5df456c999.tar.gz gcc-392e141079a198c93b19bfcd1fe2bd5df456c999.tar.bz2 |
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.c | 19 | ||||
-rw-r--r-- | libiberty/testsuite/d-demangle-expected | 24 |
2 files changed, 43 insertions, 0 deletions
diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index d74cf47..a2152cc 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); } diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected index 87ed8d3..c35185c 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -1420,5 +1420,29 @@ _D3std3uni__T6toCaseS_DQvQt12toLowerIndexFNaNbNiNewZtVii1043S_DQCjQCi10toLowerTa std.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) # --format=dlang +_D8demangle4mainFZ1xi +demangle.main().x +# +--format=dlang +_D8demangle4mainFZ4__S11xi +demangle.main().x +# +--format=dlang +_D8demangle4mainFZ1fMFNaNbNiNfZv +demangle.main().f() +# +--format=dlang +_D8demangle4mainFZ4__S11fMFNaNbNiNfZv +demangle.main().f() +# +--format=dlang +_D3mod4funcFZ__T6nestedTiZQkMFNaNbNiNfZi +mod.func().nested!(int).nested() +# +--format=dlang +_D3mod4funcFZ__T6nestedTiZ4__S1QpMFNaNbNiNfZi +mod.func().nested!(int).nested() +# +--format=dlang _D6mangle__T8fun21753VSQv6S21753S1f_DQBj10__lambda71MFNaNbNiNfZvZQCbQp mangle.fun21753!(mangle.S21753(mangle.__lambda71())).fun21753 |