summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
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
commit797f1e23f6d31fc0fee9e53174395a946ecd4943 (patch)
tree5c95e5f91898c0e5dad257347f53dafc84d10f26 /clang/lib/CodeGen
parent7184d9fc3397db1e586cec8b85c42f02dc2bdea0 (diff)
downloadbcm5719-llvm-797f1e23f6d31fc0fee9e53174395a946ecd4943.tar.gz
bcm5719-llvm-797f1e23f6d31fc0fee9e53174395a946ecd4943.zip
checking for __block variable captured by given
stmt expression, recursively walk down all substatements of the stmt expression. // rdar://10001085 llvm-svn: 138334
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 6be6fcedd36..d07347963d1 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/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)))
OpenPOWER on IntegriCloud