[cfe-commits] r68320 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle.cpp

Anders Carlsson andersca at mac.com
Thu Apr 2 09:05:20 PDT 2009


Author: andersca
Date: Thu Apr  2 11:05:20 2009
New Revision: 68320

URL: http://llvm.org/viewvc/llvm-project?rev=68320&view=rev
Log:
Mangle VarDecls correctly.

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle.cpp

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

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Thu Apr  2 11:05:20 2009
@@ -109,6 +109,16 @@
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
     return mangleFunctionDecl(FD);
   
+  if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+    if (!Context.getLangOptions().CPlusPlus ||
+        isInCLinkageSpecification(D))
+      return false;
+    
+    Out << "_Z";
+    mangleName(VD);
+    return true;
+  }
+  
   return false;
 }
 

Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=68320&r1=68319&r2=68320&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Thu Apr  2 11:05:20 2009
@@ -36,6 +36,8 @@
 // RUN: grep unmangled_function %t | count 1 &&
 extern "C" { namespace N { void unmangled_function() { } } }
 
-// RUN: grep unmangled_variable %t | count 1
+// RUN: grep unmangled_variable %t | count 1 &&
 extern "C" { namespace N { int unmangled_variable; } }
 
+// RUN: grep _ZN1N1iE %t | count 1
+namespace N { int i; }





More information about the cfe-commits mailing list