diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2012-06-19 20:53:26 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-06-19 20:53:26 +0000 |
| commit | a36cbeb464fd038bc2ca4e0fe145904701c55c04 (patch) | |
| tree | b07e51ae67a4ac811af142dd823eeebc8017890c /clang/lib/CodeGen | |
| parent | 59ceee7933da1832a270f08843fe67c7b57ea000 (diff) | |
| download | bcm5719-llvm-a36cbeb464fd038bc2ca4e0fe145904701c55c04.tar.gz bcm5719-llvm-a36cbeb464fd038bc2ca4e0fe145904701c55c04.zip | |
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
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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<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) |

