Skip to content

Commit b50801f

Browse files
author
Fariborz Jahanian
committed
block IRgen - Fixes a crash when determining if given block variable
is captured by a given statement expression. // rdar://10001085 llvm-svn: 138314
1 parent f5b0234 commit b50801f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,9 @@ static bool isCapturedBy(const VarDecl &var, const Expr *e) {
875875
return false;
876876
}
877877

878+
if (const StmtExpr *SE = dyn_cast<StmtExpr>(e))
879+
e = cast<Expr>(SE->getSubStmt()->body_back());
880+
878881
for (Stmt::const_child_range children = e->children(); children; ++children)
879882
if (isCapturedBy(var, cast<Expr>(*children)))
880883
return true;

clang/test/CodeGen/block-3.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10
2+
// rdar://10001085
3+
4+
int main() {
5+
^{
6+
__attribute__((__blocks__(byref))) int index = ({ int __a; int __b; __a < __b ? __b : __a; });
7+
};
8+
}

0 commit comments

Comments
 (0)