@@ -323,7 +323,7 @@ enum class SILFunctionTypeRepresentation : uint8_t {
323323 CFunctionPointer = uint8_t (FunctionTypeRepresentation::CFunctionPointer),
324324
325325 // / The value of the greatest AST function representation.
326- LastAST = CFunctionPointer ,
326+ LastAST = uint8_t (FunctionTypeRepresentation::Last) ,
327327
328328 // / The value of the least SIL-only function representation.
329329 FirstSIL = 8 ,
@@ -523,8 +523,8 @@ class ASTExtInfoBuilder {
523523 // If bits are added or removed, then TypeBase::NumAFTExtInfoBits
524524 // and NumMaskBits must be updated, and they must match.
525525 //
526- // |representation|noEscape|concurrent|async|throws|isolation|differentiability| SendingResult |
527- // | 0 .. 3 | 4 | 5 | 6 | 7 | 8 .. 10 | 11 .. 13 | 14 |
526+ // |representation|noEscape|concurrent|async|throws|isolation|differentiability| SendingResult | coroutine |
527+ // | 0 .. 3 | 4 | 5 | 6 | 7 | 8 .. 10 | 11 .. 13 | 14 | 15 |
528528 //
529529 enum : unsigned {
530530 RepresentationMask = 0xF << 0 ,
@@ -537,7 +537,8 @@ class ASTExtInfoBuilder {
537537 DifferentiabilityMaskOffset = 11 ,
538538 DifferentiabilityMask = 0x7 << DifferentiabilityMaskOffset,
539539 SendingResultMask = 1 << 14 ,
540- NumMaskBits = 15
540+ CoroutineMask = 1 << 15 ,
541+ NumMaskBits = 16
541542 };
542543
543544 static_assert (FunctionTypeIsolation::Mask == 0x7 , " update mask manually" );
@@ -616,6 +617,8 @@ class ASTExtInfoBuilder {
616617
617618 constexpr bool hasSendingResult () const { return bits & SendingResultMask; }
618619
620+ constexpr bool isCoroutine () const { return bits & CoroutineMask; }
621+
619622 constexpr DifferentiabilityKind getDifferentiabilityKind () const {
620623 return DifferentiabilityKind ((bits & DifferentiabilityMask) >>
621624 DifferentiabilityMaskOffset);
@@ -732,6 +735,13 @@ class ASTExtInfoBuilder {
732735 clangTypeInfo, globalActor, thrownError, lifetimeDependencies);
733736 }
734737
738+ [[nodiscard]]
739+ ASTExtInfoBuilder withCoroutine (bool coroutine = true ) const {
740+ return ASTExtInfoBuilder (
741+ coroutine ? (bits | CoroutineMask) : (bits & ~CoroutineMask),
742+ clangTypeInfo, globalActor, thrownError, lifetimeDependencies);
743+ }
744+
735745 [[nodiscard]]
736746 ASTExtInfoBuilder
737747 withDifferentiabilityKind (DifferentiabilityKind differentiability) const {
@@ -854,6 +864,8 @@ class ASTExtInfo {
854864
855865 constexpr bool isThrowing () const { return builder.isThrowing (); }
856866
867+ constexpr bool isCoroutine () const { return builder.isCoroutine (); }
868+
857869 constexpr bool hasSendingResult () const { return builder.hasSendingResult (); }
858870
859871 constexpr DifferentiabilityKind getDifferentiabilityKind () const {
@@ -917,6 +929,14 @@ class ASTExtInfo {
917929 return builder.withThrows (true , Type ()).build ();
918930 }
919931
932+ // / Helper method for changing only the coroutine field.
933+ // /
934+ // / Prefer using \c ASTExtInfoBuilder::withCoroutine for chaining.
935+ [[nodiscard]]
936+ ASTExtInfo withCoroutine (bool coroutine = true ) const {
937+ return builder.withCoroutine (coroutine).build ();
938+ }
939+
920940 // / Helper method for changing only the async field.
921941 // /
922942 // / Prefer using \c ASTExtInfoBuilder::withAsync for chaining.
0 commit comments