Skip to content

Commit 4017a16

Browse files
committed
Revert "SILGen: Simplify SILGenFunction::emitClosure()"
This change has a subtle impact on debug info emission and causes a regression with a subsequent patch I'm about to commit. This reverts commit 62d1adb.
1 parent af07642 commit 4017a16

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/SILGen/SILGenFunction.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,12 @@ void SILGenFunction::emitClosure(AbstractClosureExpr *ace) {
513513
emitStmt(ce->getBody());
514514
} else {
515515
auto *autoclosure = cast<AutoClosureExpr>(ace);
516-
emitStmt(autoclosure->getBody());
516+
// Closure expressions implicitly return the result of their body
517+
// expression.
518+
if (B.hasValidInsertionPoint()) {
519+
emitReturnExpr(ImplicitReturnLocation(ace),
520+
autoclosure->getSingleExpressionBody());
521+
}
517522
}
518523
emitEpilog(ace);
519524
}

lib/SILGen/SILGenStmt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ void SILGenFunction::emitReturnExpr(SILLocation branchLoc,
482482
RValue RV = emitRValue(ret).ensurePlusOne(*this, CleanupLocation(ret));
483483
std::move(RV).forwardAll(*this, directResults);
484484
}
485+
485486
Cleanups.emitBranchAndCleanups(ReturnDest, branchLoc, directResults);
486487
}
487488

0 commit comments

Comments
 (0)