summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 9cdb40b1218..a01aad66b07 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -227,6 +227,7 @@ const llvm::Type *CodeGenFunction::BuildByRefType(QualType Ty,
void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
QualType Ty = D.getType();
bool isByRef = D.getAttr<BlocksAttr>();
+ bool needsDispose = false;
llvm::Value *DeclPtr;
if (Ty->isConstantSizeType()) {
@@ -371,6 +372,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
Builder.CreateStore(BuildDestroyHelper(flag), destroy_helper);
}
+ needsDispose = true;
}
// Handle the cleanup attribute
@@ -388,6 +390,11 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
EmitCall(CGM.getTypes().getFunctionInfo(FD), F, Args);
}
+
+ if (needsDispose) {
+ CleanupScope scope(*this);
+ BuildBlockRelease(D, DeclPtr);
+ }
}
/// Emit an alloca (or GlobalValue depending on target)
OpenPOWER on IntegriCloud