aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-08-23 16:47:15 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-08-23 16:47:15 +0000
commit5033be1b3a6f1d1c1ab9b2d284267c8f6f531f2e (patch)
treea6b34c99f1b2c1f436b9abc95881e8b3eed00c23 /lib/CodeGen/CGDecl.cpp
parent2fef11164cbe804f7b808c07757c6f900c08d765 (diff)
checking for __block variable captured by given
stmt expression, recursively walk down all substatements of the stmt expression. // rdar://10001085 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138334 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 6be6fcedd3..d07347963d 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -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)))