@@ -238,7 +238,7 @@ enum class SILFunctionTypeRepresentation : uint8_t {
238238 CFunctionPointer = uint8_t (FunctionTypeRepresentation::CFunctionPointer),
239239
240240 // / The value of the greatest AST function representation.
241- LastAST = CFunctionPointer ,
241+ LastAST = uint8_t (FunctionTypeRepresentation::Last) ,
242242
243243 // / The value of the least SIL-only function representation.
244244 FirstSIL = 8 ,
@@ -438,8 +438,8 @@ class ASTExtInfoBuilder {
438438 // If bits are added or removed, then TypeBase::NumAFTExtInfoBits
439439 // and NumMaskBits must be updated, and they must match.
440440 //
441- // |representation|noEscape|concurrent|async|throws|isolation|differentiability| SendingResult |
442- // | 0 .. 3 | 4 | 5 | 6 | 7 | 8 .. 10 | 11 .. 13 | 14 |
441+ // |representation|noEscape|concurrent|async|throws|isolation|differentiability| SendingResult | coroutine |
442+ // | 0 .. 3 | 4 | 5 | 6 | 7 | 8 .. 10 | 11 .. 13 | 14 | 15 |
443443 //
444444 enum : unsigned {
445445 RepresentationMask = 0xF << 0 ,
@@ -452,7 +452,8 @@ class ASTExtInfoBuilder {
452452 DifferentiabilityMaskOffset = 11 ,
453453 DifferentiabilityMask = 0x7 << DifferentiabilityMaskOffset,
454454 SendingResultMask = 1 << 14 ,
455- NumMaskBits = 15
455+ CoroutineMask = 1 << 15 ,
456+ NumMaskBits = 16
456457 };
457458
458459 static_assert (FunctionTypeIsolation::Mask == 0x7 , " update mask manually" );
@@ -531,6 +532,8 @@ class ASTExtInfoBuilder {
531532
532533 constexpr bool hasSendingResult () const { return bits & SendingResultMask; }
533534
535+ constexpr bool isCoroutine () const { return bits & CoroutineMask; }
536+
534537 constexpr DifferentiabilityKind getDifferentiabilityKind () const {
535538 return DifferentiabilityKind ((bits & DifferentiabilityMask) >>
536539 DifferentiabilityMaskOffset);
@@ -647,6 +650,13 @@ class ASTExtInfoBuilder {
647650 clangTypeInfo, globalActor, thrownError, lifetimeDependencies);
648651 }
649652
653+ [[nodiscard]]
654+ ASTExtInfoBuilder withCoroutine (bool coroutine = true ) const {
655+ return ASTExtInfoBuilder (
656+ coroutine ? (bits | CoroutineMask) : (bits & ~CoroutineMask),
657+ clangTypeInfo, globalActor, thrownError, lifetimeDependencies);
658+ }
659+
650660 [[nodiscard]]
651661 ASTExtInfoBuilder
652662 withDifferentiabilityKind (DifferentiabilityKind differentiability) const {
@@ -762,6 +772,8 @@ class ASTExtInfo {
762772
763773 constexpr bool isThrowing () const { return builder.isThrowing (); }
764774
775+ constexpr bool isCoroutine () const { return builder.isCoroutine (); }
776+
765777 constexpr bool hasSendingResult () const { return builder.hasSendingResult (); }
766778
767779 constexpr DifferentiabilityKind getDifferentiabilityKind () const {
@@ -825,6 +837,14 @@ class ASTExtInfo {
825837 return builder.withThrows (true , Type ()).build ();
826838 }
827839
840+ // / Helper method for changing only the coroutine field.
841+ // /
842+ // / Prefer using \c ASTExtInfoBuilder::withCoroutine for chaining.
843+ [[nodiscard]]
844+ ASTExtInfo withCoroutine (bool coroutine = true ) const {
845+ return builder.withCoroutine (coroutine).build ();
846+ }
847+
828848 // / Helper method for changing only the async field.
829849 // /
830850 // / Prefer using \c ASTExtInfoBuilder::withAsync for chaining.
0 commit comments