@@ -194,16 +194,8 @@ class ASTExtInfoBuilder {
194194
195195 using Representation = FunctionTypeRepresentation;
196196
197- static void assertIsFunctionType (const clang::Type *);
198-
199197 ASTExtInfoBuilder (unsigned bits, ClangTypeInfo clangTypeInfo)
200- : bits(bits), clangTypeInfo(clangTypeInfo) {
201- // TODO: [clang-function-type-serialization] Once we start serializing
202- // the Clang type, we should also assert that the pointer is non-null.
203- auto Rep = Representation (bits & RepresentationMask);
204- if ((Rep == Representation::CFunctionPointer) && clangTypeInfo.type )
205- assertIsFunctionType (clangTypeInfo.type );
206- }
198+ : bits(bits), clangTypeInfo(clangTypeInfo) {}
207199
208200public:
209201 // Constructor with all defaults.
@@ -254,10 +246,7 @@ class ASTExtInfoBuilder {
254246 DifferentiabilityKind::NonDifferentiable;
255247 }
256248
257- // / Get the underlying ClangTypeInfo value if it is not the default value.
258- Optional<ClangTypeInfo> getClangTypeInfo () const {
259- return clangTypeInfo.empty () ? Optional<ClangTypeInfo>() : clangTypeInfo;
260- }
249+ ClangTypeInfo getClangTypeInfo () const { return clangTypeInfo; }
261250
262251 constexpr SILFunctionTypeRepresentation getSILRepresentation () const {
263252 unsigned rawRep = bits & RepresentationMask;
@@ -404,9 +393,7 @@ class ASTExtInfo {
404393
405394 constexpr bool isDifferentiable () const { return builder.isDifferentiable (); }
406395
407- Optional<ClangTypeInfo> getClangTypeInfo () const {
408- return builder.getClangTypeInfo ();
409- }
396+ ClangTypeInfo getClangTypeInfo () const { return builder.getClangTypeInfo (); }
410397
411398 constexpr bool hasSelfParam () const { return builder.hasSelfParam (); }
412399
@@ -518,20 +505,32 @@ class SILExtInfoBuilder {
518505 SILExtInfoBuilder (unsigned bits, ClangTypeInfo clangTypeInfo)
519506 : bits(bits), clangTypeInfo(clangTypeInfo) {}
520507
508+ static constexpr unsigned makeBits (Representation rep, bool isPseudogeneric,
509+ bool isNoEscape, bool isAsync,
510+ DifferentiabilityKind diffKind) {
511+ return ((unsigned )rep) | (isPseudogeneric ? PseudogenericMask : 0 ) |
512+ (isNoEscape ? NoEscapeMask : 0 ) | (isAsync ? AsyncMask : 0 ) |
513+ (((unsigned )diffKind << DifferentiabilityMaskOffset) &
514+ DifferentiabilityMask);
515+ }
516+
521517public:
522518 // Constructor with all defaults.
523- SILExtInfoBuilder () : bits( 0 ), clangTypeInfo( ClangTypeInfo(nullptr )) {}
519+ SILExtInfoBuilder () : SILExtInfoBuilder( 0 , ClangTypeInfo(nullptr )) {}
524520
525521 // Constructor for polymorphic type.
526522 SILExtInfoBuilder (Representation rep, bool isPseudogeneric, bool isNoEscape,
527523 bool isAsync, DifferentiabilityKind diffKind,
528524 const clang::Type *type)
529- : SILExtInfoBuilder(
530- ((unsigned )rep) | (isPseudogeneric ? PseudogenericMask : 0 ) |
531- (isNoEscape ? NoEscapeMask : 0 ) | (isAsync ? AsyncMask : 0 ) |
532- (((unsigned )diffKind << DifferentiabilityMaskOffset) &
533- DifferentiabilityMask),
534- ClangTypeInfo (type)) {}
525+ : SILExtInfoBuilder(makeBits(rep, isPseudogeneric, isNoEscape, isAsync,
526+ diffKind),
527+ ClangTypeInfo (type)) {}
528+
529+ SILExtInfoBuilder (ASTExtInfoBuilder info, bool isPseudogeneric)
530+ : SILExtInfoBuilder(makeBits(info.getSILRepresentation(), isPseudogeneric,
531+ info.isNoEscape(), info.isAsync(),
532+ info.getDifferentiabilityKind()),
533+ info.getClangTypeInfo()) {}
535534
536535 void checkInvariants () const ;
537536
@@ -566,10 +565,8 @@ class SILExtInfoBuilder {
566565 DifferentiabilityKind::NonDifferentiable;
567566 }
568567
569- // / Get the underlying ClangTypeInfo value if it is not the default value.
570- Optional<ClangTypeInfo> getClangTypeInfo () const {
571- return clangTypeInfo.empty () ? Optional<ClangTypeInfo>() : clangTypeInfo;
572- }
568+ // / Get the underlying ClangTypeInfo value.
569+ ClangTypeInfo getClangTypeInfo () const { return clangTypeInfo; }
573570
574571 constexpr bool hasSelfParam () const {
575572 switch (getRepresentation ()) {
@@ -697,9 +694,7 @@ class SILExtInfo {
697694
698695 constexpr bool isDifferentiable () const { return builder.isDifferentiable (); }
699696
700- Optional<ClangTypeInfo> getClangTypeInfo () const {
701- return builder.getClangTypeInfo ();
702- }
697+ ClangTypeInfo getClangTypeInfo () const { return builder.getClangTypeInfo (); }
703698
704699 constexpr bool hasSelfParam () const { return builder.hasSelfParam (); }
705700
0 commit comments