Mangle VarDecls correctly.

llvm-svn: 68320
This commit is contained in:
Anders Carlsson 2009-04-02 16:05:20 +00:00
parent 810679c37a
commit f2125a02db
2 changed files with 13 additions and 1 deletions

View 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;
}

View 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; }