]> granicus.if.org Git - clang/commitdiff
Mangle VarDecls correctly.
authorAnders Carlsson <andersca@mac.com>
Thu, 2 Apr 2009 16:05:20 +0000 (16:05 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 2 Apr 2009 16:05:20 +0000 (16:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68320 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/Mangle.cpp
test/CodeGenCXX/mangle.cpp

index 1c84f28d5b86c69c45652c5b08f5d66631622edf..6e62fcfc2e67ccafcf0fc14466fdbc0bdfe4e4a8 100644 (file)
@@ -109,6 +109,16 @@ bool CXXNameMangler::mangle(const NamedDecl *D) {
   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;
 }
 
index 64a3b05cfa8f7338b1d635cd2552252532a26038..e9a76c93f08e265ed1de62bf941ff467b7a7cd59 100644 (file)
@@ -36,6 +36,8 @@ namespace N { namespace N { void f() { } } }
 // 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; }