summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-09-25 06:56:03 +0000
committerJohn McCall <rjmccall@apple.com>2012-09-25 06:56:03 +0000
commitb0433eeb2e536e21a62030fd2f17d94ad2a1d2f5 (patch)
tree3b0fba774252c9e3043a44518153aa21b131efcd /clang/lib/Sema
parent446ff28df1242fcd11ce1df18af9c944afdcbdd3 (diff)
downloadbcm5719-llvm-b0433eeb2e536e21a62030fd2f17d94ad2a1d2f5.tar.gz
bcm5719-llvm-b0433eeb2e536e21a62030fd2f17d94ad2a1d2f5.zip
During jump-scope checking, build an ExprWithCleanups immediately
into the enclosing scope; this is a more accurate model but is (I believe) unnecessary in my test case due to other flaws. However, one of those flaws is now intentional: blocks which appear in return statements can be trivially observed to not extend in lifetime past the return, and so we can allow a jump past them. Do the necessary magic in IR-generation to make this work. llvm-svn: 164589
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/JumpDiagnostics.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp
index ab786c65aab..a48779a1c36 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -453,14 +453,19 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned &origParentScope)
BuildScopeInformation(AS->getSubStmt(), (newParentScope = Scopes.size()-1));
continue;
}
-
- if (const BlockExpr *BE = dyn_cast<BlockExpr>(SubStmt)) {
- const BlockDecl *BDecl = BE->getBlockDecl();
+
+ // Disallow jumps past full-expressions that use blocks with
+ // non-trivial cleanups of their captures. This is theoretically
+ // implementable but a lot of work which we haven't felt up to doing.
+ if (ExprWithCleanups *EWC = dyn_cast<ExprWithCleanups>(SubStmt)) {
+ for (unsigned i = 0, e = EWC->getNumObjects(); i != e; ++i) {
+ const BlockDecl *BDecl = EWC->getObject(i);
for (BlockDecl::capture_const_iterator ci = BDecl->capture_begin(),
ce = BDecl->capture_end(); ci != ce; ++ci) {
VarDecl *variable = ci->getVariable();
BuildScopeInformation(variable, BDecl, ParentScope);
}
+ }
}
// Recursively walk the AST.
OpenPOWER on IntegriCloud