[llvm-branch-commits] [llvm-branch] r292861 - Merging r292467:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 23 16:26:13 PST 2017


Author: hans
Date: Mon Jan 23 18:26:12 2017
New Revision: 292861

URL: http://llvm.org/viewvc/llvm-project?rev=292861&view=rev
Log:
Merging r292467:
------------------------------------------------------------------------
r292467 | compnerd | 2017-01-18 18:58:46 -0800 (Wed, 18 Jan 2017) | 7 lines

llvm-cxxfilt: filter out invalid manglings

c++filt does not attempt to demangle symbols which do not match its
expected format.  This means that the symbol must start with _Z or ___Z
(block invocation function extension).  Any other symbols are returned
as is.  Note that this is different from the behaviour of __cxa_demangle
which will demangle fragments.
------------------------------------------------------------------------

Added:
    llvm/branches/release_40/test/tools/llvm-cxxfilt/invalid.test
      - copied unchanged from r292467, llvm/trunk/test/tools/llvm-cxxfilt/invalid.test
Modified:
    llvm/branches/release_40/   (props changed)
    llvm/branches/release_40/tools/llvm-cxxfilt/llvm-cxxfilt.cpp

Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 23 18:26:12 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,291858-291859,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292323,292583,292625,292641,292667,292711,292758
+/llvm/trunk:155241,291858-291859,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292323,292467,292583,292625,292641,292667,292711,292758

Modified: llvm/branches/release_40/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/tools/llvm-cxxfilt/llvm-cxxfilt.cpp?rev=292861&r1=292860&r2=292861&view=diff
==============================================================================
--- llvm/branches/release_40/tools/llvm-cxxfilt/llvm-cxxfilt.cpp (original)
+++ llvm/branches/release_40/tools/llvm-cxxfilt/llvm-cxxfilt.cpp Mon Jan 23 18:26:12 2017
@@ -14,9 +14,12 @@
 
 using namespace llvm;
 
-static void demangle(llvm::raw_ostream &OS, const char *Mangled) {
+static void demangle(llvm::raw_ostream &OS, const std::string &Mangled) {
   int Status;
-  char *Demangled = itaniumDemangle(Mangled, nullptr, nullptr, &Status);
+  char *Demangled = nullptr;
+  if ((Mangled.size() >= 2 && Mangled.compare(0, 2, "_Z")) ||
+      (Mangled.size() >= 4 && Mangled.compare(0, 4, "___Z")))
+    Demangled = itaniumDemangle(Mangled.c_str(), nullptr, nullptr, &Status);
   OS << (Demangled ? Demangled : Mangled) << '\n';
   free(Demangled);
 }
@@ -24,7 +27,7 @@ static void demangle(llvm::raw_ostream &
 int main(int argc, char **argv) {
   if (argc == 1)
     for (std::string Mangled; std::getline(std::cin, Mangled);)
-      demangle(llvm::outs(), Mangled.c_str());
+      demangle(llvm::outs(), Mangled);
   else
     for (int I = 1; I < argc; ++I)
       demangle(llvm::outs(), argv[I]);




More information about the llvm-branch-commits mailing list