From: Anders Carlsson Date: Thu, 2 Apr 2009 16:05:20 +0000 (+0000) Subject: Mangle VarDecls correctly. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=329749c1ec1ead3c41af52260f1203e4991b4e83;p=clang Mangle VarDecls correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68320 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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(D)) return mangleFunctionDecl(FD); + if (const VarDecl *VD = dyn_cast(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; }