[PATCH] D139864: [llvm-cxxfilt] Do not consider the prefix dot as part of the demangled symbol name.

Digger Lin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 13:17:29 PDT 2023


DiggerLin updated this revision to Diff 557196.
DiggerLin marked an inline comment as done.
DiggerLin added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139864/new/

https://reviews.llvm.org/D139864

Files:
  llvm/test/tools/llvm-cxxfilt/prefix-dot.test
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp


Index: llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
===================================================================
--- llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
+++ llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
@@ -72,13 +72,21 @@
 
 static std::string demangle(const std::string &Mangled) {
   const char *DecoratedStr = Mangled.c_str();
+  std::string DotPrefix;
+
+  // Do not consider the prefix dot as part of the demangled symbol name.
+  if (DecoratedStr[0] == '.') {
+    ++DecoratedStr;
+    DotPrefix = ".";
+  }
+
   if (StripUnderscore)
     if (DecoratedStr[0] == '_')
       ++DecoratedStr;
 
   std::string Result;
   if (nonMicrosoftDemangle(DecoratedStr, Result))
-    return Result;
+    return DotPrefix + Result;
 
   std::string Prefix;
   char *Undecorated = nullptr;
@@ -91,7 +99,7 @@
     Undecorated = itaniumDemangle(DecoratedStr + 6, nullptr, nullptr, nullptr);
   }
 
-  Result = Undecorated ? Prefix + Undecorated : Mangled;
+  Result = Undecorated ? DotPrefix + Prefix + Undecorated : Mangled;
   free(Undecorated);
   return Result;
 }
Index: llvm/test/tools/llvm-cxxfilt/prefix-dot.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-cxxfilt/prefix-dot.test
@@ -0,0 +1,9 @@
+## Show that the llvm-cxxfilt does not consider the prefix dot to be part of the symbol name to be demangled.
+
+RUN: echo '._Z3Foo ._Z3f.0v' \
+RUN:      '._ZL5func0v ._Z5func1i' > %t
+RUN:      llvm-cxxfilt -n < %t | FileCheck %s
+
+CHECK: .Foo .f.0()
+CHECK: .func0()
+CHECK: .func1(int)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139864.557196.patch
Type: text/x-patch
Size: 1553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230921/7fbde729/attachment.bin>


More information about the llvm-commits mailing list