@@ -275,7 +275,8 @@ class ASTExtInfoBuilder {
275
275
: bits(bits), clangTypeInfo(clangTypeInfo) {}
276
276
277
277
public:
278
- // Constructor with all defaults.
278
+ // / An ExtInfoBuilder for a typical Swift function: @convention(swift),
279
+ // / @escaping, non-throwing, non-differentiable.
279
280
ASTExtInfoBuilder ()
280
281
: ASTExtInfoBuilder(Representation::Swift, false , false ,
281
282
DifferentiabilityKind::NonDifferentiable, nullptr ) {}
@@ -447,6 +448,8 @@ class ASTExtInfo {
447
448
};
448
449
449
450
public:
451
+ // / An ExtInfo for a typical Swift function: @convention(swift), @escaping,
452
+ // / non-throwing, non-differentiable.
450
453
ASTExtInfo () : builder() { builder.checkInvariants (); };
451
454
452
455
// / Create a builder with the same state as \c this.
@@ -598,17 +601,22 @@ class SILExtInfoBuilder {
598
601
}
599
602
600
603
public:
601
- // Constructor with all defaults.
602
- SILExtInfoBuilder () : SILExtInfoBuilder(0 , ClangTypeInfo(nullptr )) {}
604
+ // / An ExtInfoBuilder for a typical Swift function: thick, @escaping,
605
+ // / non-pseudogeneric, non-differentiable.
606
+ SILExtInfoBuilder ()
607
+ : SILExtInfoBuilder(makeBits(SILFunctionTypeRepresentation::Thick, false ,
608
+ false , false ,
609
+ DifferentiabilityKind::NonDifferentiable),
610
+ ClangTypeInfo (nullptr )) {}
603
611
604
- // Constructor for polymorphic type.
605
612
SILExtInfoBuilder (Representation rep, bool isPseudogeneric, bool isNoEscape,
606
613
bool isAsync, DifferentiabilityKind diffKind,
607
614
const clang::Type *type)
608
615
: SILExtInfoBuilder(makeBits(rep, isPseudogeneric, isNoEscape, isAsync,
609
616
diffKind),
610
617
ClangTypeInfo(type)) {}
611
618
619
+ // Constructor for polymorphic type.
612
620
SILExtInfoBuilder (ASTExtInfoBuilder info, bool isPseudogeneric)
613
621
: SILExtInfoBuilder(makeBits(info.getSILRepresentation(), isPseudogeneric,
614
622
info.isNoEscape(), info.isAsync(),
@@ -686,25 +694,30 @@ class SILExtInfoBuilder {
686
694
687
695
// Note that we don't have setters. That is by design, use
688
696
// the following with methods instead of mutating these objects.
697
+ LLVM_NODISCARD
689
698
SILExtInfoBuilder withRepresentation (Representation rep) const {
690
699
return SILExtInfoBuilder ((bits & ~RepresentationMask) | (unsigned )rep,
691
700
shouldStoreClangType (rep) ? clangTypeInfo
692
701
: ClangTypeInfo ());
693
702
}
703
+ LLVM_NODISCARD
694
704
SILExtInfoBuilder withIsPseudogeneric (bool isPseudogeneric = true ) const {
695
705
return SILExtInfoBuilder (isPseudogeneric ? (bits | PseudogenericMask)
696
706
: (bits & ~PseudogenericMask),
697
707
clangTypeInfo);
698
708
}
709
+ LLVM_NODISCARD
699
710
SILExtInfoBuilder withNoEscape (bool noEscape = true ) const {
700
711
return SILExtInfoBuilder (noEscape ? (bits | NoEscapeMask)
701
712
: (bits & ~NoEscapeMask),
702
713
clangTypeInfo);
703
714
}
715
+ LLVM_NODISCARD
704
716
SILExtInfoBuilder withAsync (bool isAsync = true ) const {
705
717
return SILExtInfoBuilder (isAsync ? (bits | AsyncMask) : (bits & ~AsyncMask),
706
718
clangTypeInfo);
707
719
}
720
+ LLVM_NODISCARD
708
721
SILExtInfoBuilder
709
722
withDifferentiabilityKind (DifferentiabilityKind differentiability) const {
710
723
return SILExtInfoBuilder (
@@ -750,13 +763,16 @@ class SILExtInfo {
750
763
};
751
764
752
765
public:
766
+ // / An ExtInfo for a typical Swift function: thick, @escaping,
767
+ // / non-pseudogeneric, non-differentiable.
753
768
SILExtInfo () : builder() { builder.checkInvariants (); };
754
769
755
770
SILExtInfo (ASTExtInfo info, bool isPseudogeneric)
756
771
: builder(info.intoBuilder(), isPseudogeneric) {
757
772
builder.checkInvariants ();
758
773
}
759
774
775
+ // / A default ExtInfo but with a Thin convention.
760
776
static SILExtInfo getThin () {
761
777
return SILExtInfoBuilder (SILExtInfoBuilder::Representation::Thin, false ,
762
778
false , false ,
0 commit comments