blocks - capturing logic of byref block variable's expression

statement initializer makes safe assumption when a substatement 
is encounterred (with a fix me).

llvm-svn: 138528
This commit is contained in:
Fariborz Jahanian 2011-08-25 00:06:26 +00:00
parent e1be996baa
commit 5c4b2ca699
1 changed files with 17 additions and 1 deletions

View File

@ -879,9 +879,25 @@ static bool isCapturedBy(const VarDecl &var, const Expr *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 (Expr *E = dyn_cast<Expr>((*BI))) {
if (isCapturedBy(var, E))
return true;
}
else if (DeclStmt *DS = dyn_cast<DeclStmt>((*BI))) {
// special case declarations
for (DeclStmt::decl_iterator I = DS->decl_begin(), E = DS->decl_end();
I != E; ++I) {
if (VarDecl *VD = dyn_cast<VarDecl>((*I))) {
Expr *Init = VD->getInit();
if (Init && isCapturedBy(var, Init))
return true;
}
}
}
else
// FIXME. Make safe assumption assuming arbitrary statements cause capturing.
// Later, provide code to poke into statements for capture analysis.
return true;
return false;
}