diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-25 00:06:26 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-25 00:06:26 +0000 |
commit | 045c84264f7c9d5b166e9a93d8fe62c777d3039c (patch) | |
tree | 0067d29a2d08f6d259e8f66c09eb68b4d2d235f7 /lib/CodeGen | |
parent | c3186597136677952aebfbcd24d3a8ef39cbd2d4 (diff) |
blocks - capturing logic of byref block variable's expression
statement initializer makes safe assumption when a substatement
is encounterred (with a fix me).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138528 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 0f6ceedb25..8fcec30c6a 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -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; } |