From a36cbeb464fd038bc2ca4e0fe145904701c55c04 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 19 Jun 2012 20:53:26 +0000 Subject: 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 llvm-svn: 158738 --- clang/lib/CodeGen/CGDecl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/lib/CodeGen/CGDecl.cpp') diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 4d4b57904c4..ff803c612fb 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -490,6 +490,14 @@ static bool isAccessedBy(const VarDecl &var, const Stmt *s) { if (const DeclRefExpr *ref = dyn_cast(e)) return (ref->getDecl() == &var); + if (const BlockExpr *be = dyn_cast(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) -- cgit v1.2.3