summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
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/CodeGen/CGStmt.cpp
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/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 4fdbfd0390d..77414bf8a46 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -743,6 +743,17 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
// Emit the result value, even if unused, to evalute the side effects.
const Expr *RV = S.getRetValue();
+ // Treat block literals in a return expression as if they appeared
+ // in their own scope. This permits a small, easily-implemented
+ // exception to our over-conservative rules about not jumping to
+ // statements following block literals with non-trivial cleanups.
+ RunCleanupsScope cleanupScope(*this);
+ if (const ExprWithCleanups *cleanups =
+ dyn_cast_or_null<ExprWithCleanups>(RV)) {
+ enterFullExpression(cleanups);
+ RV = cleanups->getSubExpr();
+ }
+
// FIXME: Clean this up by using an LValue for ReturnTemp,
// EmitStoreThroughLValue, and EmitAnyExpr.
if (S.getNRVOCandidate() && S.getNRVOCandidate()->isNRVOVariable() &&
@@ -779,6 +790,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
AggValueSlot::IsNotAliased));
}
+ cleanupScope.ForceCleanup();
EmitBranchThroughCleanup(ReturnBlock);
}
OpenPOWER on IntegriCloud