checking for __block variable captured by given

stmt expression, recursively walk down all substatements 
of the stmt expression. // rdar://10001085

llvm-svn: 138334
This commit is contained in:
Fariborz Jahanian 2011-08-23 16:47:15 +00:00
parent 7184d9fc33
commit 797f1e23f6
1 changed files with 9 additions and 2 deletions

View File

@ -875,8 +875,15 @@ static bool isCapturedBy(const VarDecl &var, const Expr *e) {
return false;
}
if (const StmtExpr *SE = dyn_cast<StmtExpr>(e))
e = cast<Expr>(SE->getSubStmt()->body_back());
if (const StmtExpr *SE = dyn_cast<StmtExpr>(e)) {
const CompoundStmt *CS = SE->getSubStmt();
for (CompoundStmt::const_body_iterator BI = CS->body_begin(), BE = CS->body_end()
;BI != BE; ++BI)
if (Expr *E = dyn_cast<Expr>((*BI)))
if (isCapturedBy(var, E))
return true;
return false;
}
for (Stmt::const_child_range children = e->children(); children; ++children)
if (isCapturedBy(var, cast<Expr>(*children)))