]> granicus.if.org Git - clang/commitdiff
checking for __block variable captured by given
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 23 Aug 2011 16:47:15 +0000 (16:47 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 23 Aug 2011 16:47:15 +0000 (16:47 +0000)
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

lib/CodeGen/CGDecl.cpp

index 6be6fcedd36c92a53c92b546617d4f9dc0758794..d07347963d171b5058ec76bd8b695d9ef408c61f 100644 (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)))