[PATCH] D104358: [Demangle][Rust] Parse dot suffix

Tomasz Miąsko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 16 00:07:56 PDT 2021


tmiasko created this revision.
tmiasko added a reviewer: dblaikie.
Herald added subscribers: JDevlieghere, hiraditya.
tmiasko requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104358

Files:
  llvm/lib/Demangle/RustDemangle.cpp
  llvm/test/Demangle/rust.test


Index: llvm/test/Demangle/rust.test
===================================================================
--- llvm/test/Demangle/rust.test
+++ llvm/test/Demangle/rust.test
@@ -448,6 +448,14 @@
 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
Index: llvm/lib/Demangle/RustDemangle.cpp
===================================================================
--- llvm/lib/Demangle/RustDemangle.cpp
+++ llvm/lib/Demangle/RustDemangle.cpp
@@ -113,11 +113,20 @@
 
   demanglePath(rust_demangle::InType::No);
 
-  if (Position != Input.size()) {
+  if (Position != Input.size() && look() != '.') {
     SwapAndRestore<bool> SavePrint(Print, false);
     demanglePath(InType::No);
   }
 
+  // An extension allowing an arbitrary dot suffix.
+  if (consumeIf('.')) {
+    auto Suffix = Input.substr(Position);
+    Position += Suffix.size();
+    print(" (");
+    print(Suffix);
+    print(")");
+  }
+
   if (Position != Input.size())
     Error = true;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104358.352352.patch
Type: text/x-patch
Size: 1126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210616/1a75cf81/attachment.bin>


More information about the llvm-commits mailing list