[Demangle][Rust] Parse dot suffix

Allow mangled names to include an arbitrary dot suffix, akin to vendor
specific suffix in Itanium mangling.

Primary motivation is a support for symbols renamed during ThinLTO
import / promotion (ThinLTO is the default configuration for optimized
builds in rustc).

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D104358
This commit is contained in:
Tomasz Miąsko
2021-06-18 09:27:50 +02:00
parent 6de741de08
commit 2a5bb9c877
2 changed files with 17 additions and 1 deletions

View File

@@ -109,7 +109,9 @@ bool Demangler::demangle(StringView Mangled) {
Error = true;
return false;
}
Input = Mangled;
size_t Dot = Mangled.find('.');
Input = Mangled.substr(0, Dot);
StringView Suffix = Mangled.dropFront(Dot);
demanglePath(rust_demangle::InType::No);
@@ -121,6 +123,12 @@ bool Demangler::demangle(StringView Mangled) {
if (Position != Input.size())
Error = true;
if (!Suffix.empty()) {
print(" (");
print(Suffix);
print(")");
}
return !Error;
}

View File

@@ -448,6 +448,14 @@ CHECK: _RIC7backrefSB9_E
CHECK: _RIC7backrefKBa_E
_RIC7backrefKBa_E
; Dot suffix
CHECK: dot (.llvm.1234)
_RC3dot.llvm.1234
CHECK: dot (.llvm.6789)
_RC3dotC5crate.llvm.6789
; Invalid mangled characters
CHECK: _RNvC2a.1c