[cfe-commits] r95377 - /cfe/trunk/lib/CodeGen/Mangle.cpp

Anders Carlsson andersca at mac.com
Thu Feb 4 23:31:38 PST 2010


Author: andersca
Date: Fri Feb  5 01:31:37 2010
New Revision: 95377

URL: http://llvm.org/viewvc/llvm-project?rev=95377&view=rev
Log:
Check in a mangle checker that's turned off by default.

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=95377&r1=95376&r2=95377&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Fri Feb  5 01:31:37 2010
@@ -26,6 +26,13 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "CGVtable.h"
+
+#define MANGLE_CHECKER 0
+
+#if MANGLE_CHECKER
+#include <cxxabi.h>
+#endif
+
 using namespace clang;
 using namespace CodeGen;
 
@@ -69,6 +76,17 @@
                  const CXXDestructorDecl *D, CXXDtorType Type)
     : Context(C), Out(Res), Structor(getStructor(D)), StructorType(Type) { }
 
+#if MANGLE_CHECKER
+  ~CXXNameMangler() {
+    if (Out.str()[0] == '\01')
+      return;
+    
+    int status = 0;
+    char *result = abi::__cxa_demangle(Out.str().str().c_str(), 0, 0, &status);
+    assert(status == 0 && "Could not demangle mangled name!");
+    free(result);
+  }
+#endif
   llvm::raw_svector_ostream &getStream() { return Out; }
 
   void mangle(const NamedDecl *D, llvm::StringRef Prefix = "_Z");





More information about the cfe-commits mailing list