[cfe-commits] r138314 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGen/block-3.c

Fariborz Jahanian fjahanian at apple.com
Mon Aug 22 17:27:49 PDT 2011


Author: fjahanian
Date: Mon Aug 22 19:27:49 2011
New Revision: 138314

URL: http://llvm.org/viewvc/llvm-project?rev=138314&view=rev
Log:
block IRgen - Fixes a crash when determining if given block variable
is captured by a given statement expression. // rdar://10001085

Added:
    cfe/trunk/test/CodeGen/block-3.c
Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=138314&r1=138313&r2=138314&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Mon Aug 22 19:27:49 2011
@@ -875,6 +875,9 @@
     return false;
   }
 
+  if (const StmtExpr *SE = dyn_cast<StmtExpr>(e))
+    e = cast<Expr>(SE->getSubStmt()->body_back());
+    
   for (Stmt::const_child_range children = e->children(); children; ++children)
     if (isCapturedBy(var, cast<Expr>(*children)))
       return true;

Added: cfe/trunk/test/CodeGen/block-3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/block-3.c?rev=138314&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/block-3.c (added)
+++ cfe/trunk/test/CodeGen/block-3.c Mon Aug 22 19:27:49 2011
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 
+// rdar://10001085
+
+int main() {
+  ^{
+                __attribute__((__blocks__(byref))) int index = ({ int __a; int __b; __a < __b ? __b : __a; });
+   };
+}





More information about the cfe-commits mailing list