diff options
author | Mike Stump <mrs@apple.com> | 2009-03-05 01:23:13 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-03-05 01:23:13 +0000 |
commit | 797b6327571f9d7b1c45404a56ddcbf9b9298ae8 (patch) | |
tree | 606c641fbf57704185ed3cf437a2434de275fb1d /lib/CodeGen/CGDecl.cpp | |
parent | 7833ed2a6eb10750572fb7b7dbb16741fe1b00ec (diff) |
Add codegen support for __block variables to call _Block_object_dispose as necessary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66117 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 9cdb40b121..a01aad66b0 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/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) |