@@ -1043,15 +1043,18 @@ void SILGenFunction::emitFunction(FuncDecl *fd) {
10431043 MagicFunctionName = SILGenModule::getMagicFunctionName (fd);
10441044
10451045 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 ());
10481049
10491050 if (fd->isDistributedActorFactory ()) {
10501051 // Synthesize the factory function body
10511052 emitDistributedActorFactory (fd);
10521053 } else {
1053- prepareEpilog (fd->getResultInterfaceType (),
1054- fd->getEffectiveThrownErrorType (), CleanupLocation (fd));
1054+ prepareEpilog (fd,
1055+ fd->getResultInterfaceType (),
1056+ fd->getEffectiveThrownErrorType (),
1057+ CleanupLocation (fd));
10551058
10561059 if (fd->requiresUnavailableDeclABICompatibilityStubs ())
10571060 emitApplyOfUnavailableCodeReached ();
@@ -1071,15 +1074,17 @@ void SILGenFunction::emitFunction(FuncDecl *fd) {
10711074void SILGenFunction::emitClosure (AbstractClosureExpr *ace) {
10721075 MagicFunctionName = SILGenModule::getMagicFunctionName (ace);
10731076 OrigFnType = SGM.M .Types .getConstantAbstractionPattern (SILDeclRef (ace));
1074-
1077+
10751078 auto resultIfaceTy = ace->getResultType ()->mapTypeOutOfContext ();
1079+ llvm::Optional<Type> errorIfaceTy;
1080+ if (auto optErrorTy = ace->getEffectiveThrownType ())
1081+ errorIfaceTy = (*optErrorTy)->mapTypeOutOfContext ();
10761082 auto captureInfo = SGM.M .Types .getLoweredLocalCaptures (
10771083 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);
10831088
10841089 emitProfilerIncrement (ace);
10851090 if (auto *ce = dyn_cast<ClosureExpr>(ace)) {
@@ -1553,15 +1558,15 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, Expr *value,
15531558
15541559 auto captureInfo = SGM.M .Types .getLoweredLocalCaptures (function);
15551560 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 ());
15581563 if (EmitProfilerIncrement) {
15591564 // Emit a profiler increment for the top-level value, not looking through
15601565 // any function conversions. This is necessary as the counter would have
15611566 // been recorded for this expression, not the sub-expression.
15621567 emitProfilerIncrement (topLevelValue);
15631568 }
1564- prepareEpilog (interfaceType, llvm::None, CleanupLocation (Loc));
1569+ prepareEpilog (dc, interfaceType, llvm::None, CleanupLocation (Loc));
15651570
15661571 {
15671572 llvm::Optional<SILGenFunction::OpaqueValueRAII> opaqueValue;
@@ -1621,10 +1626,14 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, VarDecl *var) {
16211626 }
16221627 }
16231628
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 (),
16261635 /* ignored parameters*/ 0 );
1627- prepareEpilog (interfaceType, llvm::None, CleanupLocation (loc));
1636+ prepareEpilog (dc, interfaceType, llvm::None, CleanupLocation (loc));
16281637
16291638 auto pbd = var->getParentPatternBinding ();
16301639 const auto i = pbd->getPatternEntryIndexForVarDecl (var);
@@ -1676,11 +1685,11 @@ void SILGenFunction::emitGeneratorFunction(
16761685
16771686 auto *dc = function.getDecl ()->getInnermostDeclContext ();
16781687 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);
16821691
1683- prepareEpilog (resultInterfaceType, llvm::None, CleanupLocation (loc));
1692+ prepareEpilog (dc, resultInterfaceType, llvm::None, CleanupLocation (loc));
16841693
16851694 emitStmt (body);
16861695
0 commit comments