[llvm] a381343 - [llvm-cxxfilt] Use nonMicrosoftDemangle for demangling NFC

Tomasz Miąsko via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 16 04:35:23 PDT 2021


Author: Tomasz Miąsko
Date: 2021-10-16T13:32:17+02:00
New Revision: a3813438ae1c2d688f7bccc4501a172f17b7a505

URL: https://github.com/llvm/llvm-project/commit/a3813438ae1c2d688f7bccc4501a172f17b7a505
DIFF: https://github.com/llvm/llvm-project/commit/a3813438ae1c2d688f7bccc4501a172f17b7a505.diff

LOG: [llvm-cxxfilt] Use nonMicrosoftDemangle for demangling NFC

Reviewed By: dblaikie, jhenderson

Part of https://reviews.llvm.org/D110664

Added: 
    

Modified: 
    llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
index 0a6d4b50ecf37..ccfaaa96deb21 100644
--- a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
+++ b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
@@ -65,34 +65,27 @@ static void error(const Twine &Message) {
 }
 
 static std::string demangle(const std::string &Mangled) {
-  int Status;
-  std::string Prefix;
-
   const char *DecoratedStr = Mangled.c_str();
   if (StripUnderscore)
     if (DecoratedStr[0] == '_')
       ++DecoratedStr;
-  size_t DecoratedLength = strlen(DecoratedStr);
 
+  std::string Result;
+  if (nonMicrosoftDemangle(DecoratedStr, Result))
+    return Result;
+
+  std::string Prefix;
   char *Undecorated = nullptr;
 
-  if (Types ||
-      ((DecoratedLength >= 2 && strncmp(DecoratedStr, "_Z", 2) == 0) ||
-       (DecoratedLength >= 4 && strncmp(DecoratedStr, "___Z", 4) == 0)))
-    Undecorated = itaniumDemangle(DecoratedStr, nullptr, nullptr, &Status);
+  if (Types)
+    Undecorated = itaniumDemangle(DecoratedStr, nullptr, nullptr, nullptr);
 
-  if (!Undecorated &&
-      (DecoratedLength > 6 && strncmp(DecoratedStr, "__imp_", 6) == 0)) {
+  if (!Undecorated && strncmp(DecoratedStr, "__imp_", 6) == 0) {
     Prefix = "import thunk for ";
-    Undecorated = itaniumDemangle(DecoratedStr + 6, nullptr, nullptr, &Status);
-  }
-
-  if (!Undecorated &&
-      (DecoratedLength >= 2 && strncmp(DecoratedStr, "_R", 2) == 0)) {
-    Undecorated = rustDemangle(DecoratedStr, nullptr, nullptr, &Status);
+    Undecorated = itaniumDemangle(DecoratedStr + 6, nullptr, nullptr, nullptr);
   }
 
-  std::string Result(Undecorated ? Prefix + Undecorated : Mangled);
+  Result = Undecorated ? Prefix + Undecorated : Mangled;
   free(Undecorated);
   return Result;
 }


        


More information about the llvm-commits mailing list