diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-23 00:27:49 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-23 00:27:49 +0000 |
| commit | b50801f0490369d12b3deb6bdcefe8d6fe72a6bb (patch) | |
| tree | 2ab1b50bebb6946d4be9f847c57dc8143847c7f3 /clang | |
| parent | f5b0234992365f342019af0a468d255c65a869f4 (diff) | |
| download | bcm5719-llvm-b50801f0490369d12b3deb6bdcefe8d6fe72a6bb.tar.gz bcm5719-llvm-b50801f0490369d12b3deb6bdcefe8d6fe72a6bb.zip | |
block IRgen - Fixes a crash when determining if given block variable
is captured by a given statement expression. // rdar://10001085
llvm-svn: 138314
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 3 | ||||
| -rw-r--r-- | clang/test/CodeGen/block-3.c | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 6e65e88bceb..6be6fcedd36 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -875,6 +875,9 @@ 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()); + for (Stmt::const_child_range children = e->children(); children; ++children) if (isCapturedBy(var, cast<Expr>(*children))) return true; diff --git a/clang/test/CodeGen/block-3.c b/clang/test/CodeGen/block-3.c new file mode 100644 index 00000000000..95cb6a735c7 --- /dev/null +++ b/clang/test/CodeGen/block-3.c @@ -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; }); + }; +} |

