aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-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());
}