aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-04-02 16:05:20 +0000
committerAnders Carlsson <andersca@mac.com>2009-04-02 16:05:20 +0000
commit329749c1ec1ead3c41af52260f1203e4991b4e83 (patch)
tree1636f0569afd808e7633cce8eb82a155bd62684f
parent43f1740b7eeef0f39479474f199ec7cfa290b57e (diff)
Mangle VarDecls correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68320 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/Mangle.cpp10
-rw-r--r--test/CodeGenCXX/mangle.cpp4
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 1c84f28d5b..6e62fcfc2e 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -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;
}
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index 64a3b05cfa..e9a76c93f0 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -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; }