aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-04-02 03:29:47 +0000
committerAnders Carlsson <andersca@mac.com>2009-04-02 03:29:47 +0000
commit17c35acad1248ec919e76992c03b47d848502a15 (patch)
tree890b4f8cad5979b79d05c482fbff48f96a14717b /lib/CodeGen
parentfe057ac36b9a76cdfa37dfa003f986461fb5fb98 (diff)
When compiling C++ code, always mangle the names of static block var decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68280 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGDecl.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 5a5bb62b06..1277404e16 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -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());
}