[llvm] 2a5bb9c - [Demangle][Rust] Parse dot suffix
Tomasz Miąsko via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 00:31:14 PDT 2021
Author: Tomasz Miąsko
Date: 2021-06-18T09:29:45+02:00
New Revision: 2a5bb9c877f23224ee6b789054b4edfa17b4fd30
URL: https://github.com/llvm/llvm-project/commit/2a5bb9c877f23224ee6b789054b4edfa17b4fd30
DIFF: https://github.com/llvm/llvm-project/commit/2a5bb9c877f23224ee6b789054b4edfa17b4fd30.diff
LOG: [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
Added:
Modified:
llvm/lib/Demangle/RustDemangle.cpp
llvm/test/Demangle/rust.test
Removed:
################################################################################
diff --git a/llvm/lib/Demangle/RustDemangle.cpp b/llvm/lib/Demangle/RustDemangle.cpp
index 919a668a5e5f3..39db8fdc583ef 100644
--- a/llvm/lib/Demangle/RustDemangle.cpp
+++ b/llvm/lib/Demangle/RustDemangle.cpp
@@ -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;
}
diff --git a/llvm/test/Demangle/rust.test b/llvm/test/Demangle/rust.test
index 7e421d04742f2..b5d3a160ff632 100644
--- a/llvm/test/Demangle/rust.test
+++ b/llvm/test/Demangle/rust.test
@@ -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
More information about the llvm-commits
mailing list