aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-06-19 20:53:26 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-06-19 20:53:26 +0000
commitddfc8a1e68ac67d748ca918acac8f1c78a51395c (patch)
treec1b989a751bf70010e7b432f15e1d1341e627a92 /lib/CodeGen
parentc9480dd03522f0bab5fff7d30402cb7ee31117dc (diff)
objc-arc: captured block variable accessed in its block literal
initializer need be null initialized before initializer takes hold, just like any other initialized retainable object pointer. // rdar://11016025 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158738 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGDecl.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 4d4b57904c..ff803c612f 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -490,6 +490,14 @@ static bool isAccessedBy(const VarDecl &var, const Stmt *s) {
if (const DeclRefExpr *ref = dyn_cast<DeclRefExpr>(e))
return (ref->getDecl() == &var);
+ if (const BlockExpr *be = dyn_cast<BlockExpr>(e)) {
+ const BlockDecl *block = be->getBlockDecl();
+ for (BlockDecl::capture_const_iterator i = block->capture_begin(),
+ e = block->capture_end(); i != e; ++i) {
+ if (i->getVariable() == &var)
+ return true;
+ }
+ }
}
for (Stmt::const_child_range children = s->children(); children; ++children)