When compiling C++ code, always mangle the names of static block var decls.

llvm-svn: 68280
This commit is contained in:
Anders Carlsson
2009-04-02 03:29:47 +00:00
parent 7e70204613
commit f7e01ffa4a

View File

@@ -86,19 +86,25 @@ CodeGenFunction::CreateStaticBlockVarDecl(const VarDecl &D,
QualType Ty = D.getType();
assert(Ty->isConstantSizeType() && "VLAs can't be static");
std::string ContextName;
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl))
ContextName = CGM.getMangledName(FD);
else if (isa<ObjCMethodDecl>(CurFuncDecl))
ContextName = std::string(CurFn->getNameStart(),
CurFn->getNameStart() + CurFn->getNameLen());
else
assert(0 && "Unknown context for block var decl");
std::string Name;
if (getContext().getLangOptions().CPlusPlus) {
Name = CGM.getMangledName(&D);
} else {
std::string ContextName;
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl))
ContextName = CGM.getMangledName(FD);
else if (isa<ObjCMethodDecl>(CurFuncDecl))
ContextName = std::string(CurFn->getNameStart(),
CurFn->getNameStart() + CurFn->getNameLen());
else
assert(0 && "Unknown context for block var decl");
Name = ContextName + Separator + D.getNameAsString();
}
const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty);
return new llvm::GlobalVariable(LTy, Ty.isConstant(getContext()), Linkage,
llvm::Constant::getNullValue(LTy),
ContextName + Separator + D.getNameAsString(),
llvm::Constant::getNullValue(LTy), Name,
&CGM.getModule(), 0, Ty.getAddressSpace());
}