@@ -1043,15 +1043,18 @@ void SILGenFunction::emitFunction(FuncDecl *fd) {
1043
1043
MagicFunctionName = SILGenModule::getMagicFunctionName (fd);
1044
1044
1045
1045
auto captureInfo = SGM.M .Types .getLoweredLocalCaptures (SILDeclRef (fd));
1046
- emitProlog (captureInfo, fd->getParameters (), fd->getImplicitSelfDecl (), fd,
1047
- fd->getResultInterfaceType (), fd->hasThrows (), fd->getThrowsLoc ());
1046
+ emitProlog (fd, captureInfo, fd->getParameters (), fd->getImplicitSelfDecl (),
1047
+ fd->getResultInterfaceType (), fd->getEffectiveThrownErrorType (),
1048
+ fd->getThrowsLoc ());
1048
1049
1049
1050
if (fd->isDistributedActorFactory ()) {
1050
1051
// Synthesize the factory function body
1051
1052
emitDistributedActorFactory (fd);
1052
1053
} else {
1053
- prepareEpilog (fd->getResultInterfaceType (),
1054
- fd->getEffectiveThrownErrorType (), CleanupLocation (fd));
1054
+ prepareEpilog (fd,
1055
+ fd->getResultInterfaceType (),
1056
+ fd->getEffectiveThrownErrorType (),
1057
+ CleanupLocation (fd));
1055
1058
1056
1059
if (fd->requiresUnavailableDeclABICompatibilityStubs ())
1057
1060
emitApplyOfUnavailableCodeReached ();
@@ -1071,15 +1074,17 @@ void SILGenFunction::emitFunction(FuncDecl *fd) {
1071
1074
void SILGenFunction::emitClosure (AbstractClosureExpr *ace) {
1072
1075
MagicFunctionName = SILGenModule::getMagicFunctionName (ace);
1073
1076
OrigFnType = SGM.M .Types .getConstantAbstractionPattern (SILDeclRef (ace));
1074
-
1077
+
1075
1078
auto resultIfaceTy = ace->getResultType ()->mapTypeOutOfContext ();
1079
+ llvm::Optional<Type> errorIfaceTy;
1080
+ if (auto optErrorTy = ace->getEffectiveThrownType ())
1081
+ errorIfaceTy = (*optErrorTy)->mapTypeOutOfContext ();
1076
1082
auto captureInfo = SGM.M .Types .getLoweredLocalCaptures (
1077
1083
SILDeclRef (ace));
1078
- emitProlog (captureInfo, ace->getParameters (), /* selfParam=*/ nullptr ,
1079
- ace, resultIfaceTy, ace->isBodyThrowing (), ace->getLoc (),
1080
- OrigFnType);
1081
- prepareEpilog (resultIfaceTy, ace->getEffectiveThrownType (),
1082
- CleanupLocation (ace));
1084
+ emitProlog (ace, captureInfo, ace->getParameters (), /* selfParam=*/ nullptr ,
1085
+ resultIfaceTy, errorIfaceTy, ace->getLoc (), OrigFnType);
1086
+ prepareEpilog (ace, resultIfaceTy, errorIfaceTy,
1087
+ CleanupLocation (ace), OrigFnType);
1083
1088
1084
1089
emitProfilerIncrement (ace);
1085
1090
if (auto *ce = dyn_cast<ClosureExpr>(ace)) {
@@ -1553,15 +1558,15 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, Expr *value,
1553
1558
1554
1559
auto captureInfo = SGM.M .Types .getLoweredLocalCaptures (function);
1555
1560
auto interfaceType = value->getType ()->mapTypeOutOfContext ();
1556
- emitProlog (captureInfo, params, /* selfParam=*/ nullptr ,
1557
- dc, interfaceType, /* throws =*/ false , SourceLoc ());
1561
+ emitProlog (dc, captureInfo, params, /* selfParam=*/ nullptr , interfaceType ,
1562
+ /* errorType =*/ llvm::None , SourceLoc ());
1558
1563
if (EmitProfilerIncrement) {
1559
1564
// Emit a profiler increment for the top-level value, not looking through
1560
1565
// any function conversions. This is necessary as the counter would have
1561
1566
// been recorded for this expression, not the sub-expression.
1562
1567
emitProfilerIncrement (topLevelValue);
1563
1568
}
1564
- prepareEpilog (interfaceType, llvm::None, CleanupLocation (Loc));
1569
+ prepareEpilog (dc, interfaceType, llvm::None, CleanupLocation (Loc));
1565
1570
1566
1571
{
1567
1572
llvm::Optional<SILGenFunction::OpaqueValueRAII> opaqueValue;
@@ -1621,10 +1626,14 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, VarDecl *var) {
1621
1626
}
1622
1627
}
1623
1628
1624
- emitBasicProlog (/* paramList*/ nullptr , /* selfParam*/ nullptr ,
1625
- interfaceType, dc, /* throws=*/ false ,SourceLoc (),
1629
+ emitBasicProlog (dc,
1630
+ /* paramList*/ nullptr ,
1631
+ /* selfParam*/ nullptr ,
1632
+ interfaceType,
1633
+ /* errorType=*/ llvm::None,
1634
+ /* throwsLoc=*/ SourceLoc (),
1626
1635
/* ignored parameters*/ 0 );
1627
- prepareEpilog (interfaceType, llvm::None, CleanupLocation (loc));
1636
+ prepareEpilog (dc, interfaceType, llvm::None, CleanupLocation (loc));
1628
1637
1629
1638
auto pbd = var->getParentPatternBinding ();
1630
1639
const auto i = pbd->getPatternEntryIndexForVarDecl (var);
@@ -1676,11 +1685,11 @@ void SILGenFunction::emitGeneratorFunction(
1676
1685
1677
1686
auto *dc = function.getDecl ()->getInnermostDeclContext ();
1678
1687
auto captureInfo = SGM.M .Types .getLoweredLocalCaptures (function);
1679
- emitProlog (captureInfo, ParameterList::createEmpty (getASTContext ()),
1680
- /* selfParam=*/ nullptr , dc, resultInterfaceType, /* throws= */ false ,
1681
- SourceLoc (), pattern);
1688
+ emitProlog (dc, captureInfo, ParameterList::createEmpty (getASTContext ()),
1689
+ /* selfParam=*/ nullptr , resultInterfaceType,
1690
+ /* errorType= */ llvm::None, SourceLoc (), pattern);
1682
1691
1683
- prepareEpilog (resultInterfaceType, llvm::None, CleanupLocation (loc));
1692
+ prepareEpilog (dc, resultInterfaceType, llvm::None, CleanupLocation (loc));
1684
1693
1685
1694
emitStmt (body);
1686
1695
0 commit comments