@@ -390,42 +390,47 @@ class ASTExtInfoBuilder {
390390 unsigned bits; // Naturally sized for speed.
391391
392392 ClangTypeInfo clangTypeInfo;
393+
393394 Type globalActor;
394395 Type thrownError;
395396
397+ LifetimeDependenceInfo lifetimeDependenceInfo;
398+
396399 using Representation = FunctionTypeRepresentation;
397400
398- ASTExtInfoBuilder (
399- unsigned bits, ClangTypeInfo clangTypeInfo, Type globalActor,
400- Type thrownError
401- ) : bits(bits), clangTypeInfo(clangTypeInfo), globalActor(globalActor),
402- thrownError (thrownError) {}
401+ ASTExtInfoBuilder (unsigned bits, ClangTypeInfo clangTypeInfo,
402+ Type globalActor, Type thrownError,
403+ LifetimeDependenceInfo lifetimeDependenceInfo)
404+ : bits(bits), clangTypeInfo(clangTypeInfo), globalActor(globalActor),
405+ thrownError (thrownError),
406+ lifetimeDependenceInfo(lifetimeDependenceInfo) {}
403407
404408public:
405409 // / An ExtInfoBuilder for a typical Swift function: @convention(swift),
406410 // / @escaping, non-throwing, non-differentiable.
407411 ASTExtInfoBuilder ()
408412 : ASTExtInfoBuilder(Representation::Swift, false , false , Type(),
409413 DifferentiabilityKind::NonDifferentiable, nullptr,
410- Type()) {}
414+ Type(), LifetimeDependenceInfo() ) {}
411415
412416 // Constructor for polymorphic type.
413417 ASTExtInfoBuilder (Representation rep, bool throws, Type thrownError)
414418 : ASTExtInfoBuilder(rep, false , throws, thrownError,
415419 DifferentiabilityKind::NonDifferentiable, nullptr ,
416- Type ()) {}
420+ Type (), LifetimeDependenceInfo() ) {}
417421
418422 // Constructor with no defaults.
419423 ASTExtInfoBuilder (Representation rep, bool isNoEscape, bool throws,
420- Type thrownError,
421- DifferentiabilityKind diffKind, const clang::Type *type,
422- Type globalActor )
424+ Type thrownError, DifferentiabilityKind diffKind,
425+ const clang::Type *type, Type globalActor ,
426+ LifetimeDependenceInfo lifetimeDependenceInfo )
423427 : ASTExtInfoBuilder(
424428 ((unsigned )rep) | (isNoEscape ? NoEscapeMask : 0 ) |
425429 (throws ? ThrowsMask : 0 ) |
426430 (((unsigned )diffKind << DifferentiabilityMaskOffset) &
427431 DifferentiabilityMask),
428- ClangTypeInfo(type), globalActor, thrownError) {}
432+ ClangTypeInfo(type), globalActor, thrownError,
433+ lifetimeDependenceInfo) {}
429434
430435 void checkInvariants () const ;
431436
@@ -465,6 +470,10 @@ class ASTExtInfoBuilder {
465470 Type getGlobalActor () const { return globalActor; }
466471 Type getThrownError () const { return thrownError; }
467472
473+ LifetimeDependenceInfo getLifetimeDependenceInfo () const {
474+ return lifetimeDependenceInfo;
475+ }
476+
468477 constexpr bool hasSelfParam () const {
469478 switch (getSILRepresentation ()) {
470479 case SILFunctionTypeRepresentation::Thick:
@@ -498,31 +507,31 @@ class ASTExtInfoBuilder {
498507 return ASTExtInfoBuilder ((bits & ~RepresentationMask) | (unsigned )rep,
499508 shouldStoreClangType (rep) ? clangTypeInfo
500509 : ClangTypeInfo (),
501- globalActor, thrownError);
510+ globalActor, thrownError, lifetimeDependenceInfo );
502511 }
503512 [[nodiscard]]
504513 ASTExtInfoBuilder withNoEscape (bool noEscape = true ) const {
505- return ASTExtInfoBuilder (noEscape ? (bits | NoEscapeMask)
506- : (bits & ~NoEscapeMask),
507- clangTypeInfo, globalActor, thrownError);
514+ return ASTExtInfoBuilder (
515+ noEscape ? (bits | NoEscapeMask) : (bits & ~NoEscapeMask),
516+ clangTypeInfo, globalActor, thrownError, lifetimeDependenceInfo );
508517 }
509518 [[nodiscard]]
510519 ASTExtInfoBuilder withConcurrent (bool concurrent = true ) const {
511- return ASTExtInfoBuilder (concurrent ? (bits | SendableMask)
512- : (bits & ~SendableMask),
513- clangTypeInfo, globalActor, thrownError);
520+ return ASTExtInfoBuilder (
521+ concurrent ? (bits | SendableMask) : (bits & ~SendableMask),
522+ clangTypeInfo, globalActor, thrownError, lifetimeDependenceInfo );
514523 }
515524 [[nodiscard]]
516525 ASTExtInfoBuilder withAsync (bool async = true ) const {
517- return ASTExtInfoBuilder (async ? (bits | AsyncMask)
518- : (bits & ~AsyncMask) ,
519- clangTypeInfo, globalActor, thrownError );
526+ return ASTExtInfoBuilder (async ? (bits | AsyncMask) : (bits & ~AsyncMask),
527+ clangTypeInfo, globalActor, thrownError ,
528+ lifetimeDependenceInfo );
520529 }
521530 [[nodiscard]]
522531 ASTExtInfoBuilder withThrows (bool throws, Type thrownError) const {
523532 return ASTExtInfoBuilder (
524533 throws ? (bits | ThrowsMask) : (bits & ~ThrowsMask), clangTypeInfo,
525- globalActor, thrownError);
534+ globalActor, thrownError, lifetimeDependenceInfo );
526535 }
527536 [[nodiscard]]
528537 ASTExtInfoBuilder withThrows () const {
@@ -534,12 +543,12 @@ class ASTExtInfoBuilder {
534543 return ASTExtInfoBuilder (
535544 (bits & ~DifferentiabilityMask) |
536545 ((unsigned )differentiability << DifferentiabilityMaskOffset),
537- clangTypeInfo, globalActor, thrownError);
546+ clangTypeInfo, globalActor, thrownError, lifetimeDependenceInfo );
538547 }
539548 [[nodiscard]]
540549 ASTExtInfoBuilder withClangFunctionType (const clang::Type *type) const {
541- return ASTExtInfoBuilder (
542- bits, ClangTypeInfo (type), globalActor, thrownError);
550+ return ASTExtInfoBuilder (bits, ClangTypeInfo (type), globalActor,
551+ thrownError, lifetimeDependenceInfo );
543552 }
544553
545554 // / Put a SIL representation in the ExtInfo.
@@ -553,19 +562,27 @@ class ASTExtInfoBuilder {
553562 return ASTExtInfoBuilder ((bits & ~RepresentationMask) | (unsigned )rep,
554563 shouldStoreClangType (rep) ? clangTypeInfo
555564 : ClangTypeInfo (),
556- globalActor, thrownError);
565+ globalActor, thrownError, lifetimeDependenceInfo );
557566 }
558567
559568 [[nodiscard]]
560569 ASTExtInfoBuilder withGlobalActor (Type globalActor) const {
561- return ASTExtInfoBuilder (bits, clangTypeInfo, globalActor, thrownError);
570+ return ASTExtInfoBuilder (bits, clangTypeInfo, globalActor, thrownError,
571+ lifetimeDependenceInfo);
572+ }
573+
574+ [[nodiscard]] ASTExtInfoBuilder withLifetimeDependenceInfo (
575+ LifetimeDependenceInfo lifetimeDependenceInfo) const {
576+ return ASTExtInfoBuilder (bits, clangTypeInfo, globalActor, thrownError,
577+ lifetimeDependenceInfo);
562578 }
563579
564580 bool isEqualTo (ASTExtInfoBuilder other, bool useClangTypes) const {
565581 return bits == other.bits &&
566- (useClangTypes ? (clangTypeInfo == other.clangTypeInfo ) : true ) &&
567- globalActor.getPointer () == other.globalActor .getPointer () &&
568- thrownError.getPointer () == other.thrownError .getPointer ();
582+ (useClangTypes ? (clangTypeInfo == other.clangTypeInfo ) : true ) &&
583+ globalActor.getPointer () == other.globalActor .getPointer () &&
584+ thrownError.getPointer () == other.thrownError .getPointer () &&
585+ lifetimeDependenceInfo == other.lifetimeDependenceInfo ;
569586 }
570587
571588 constexpr std::tuple<unsigned , const void *, const void *, const void *>
@@ -594,8 +611,9 @@ class ASTExtInfo {
594611 ASTExtInfo (ASTExtInfoBuilder builder) : builder(builder) {}
595612
596613 ASTExtInfo (unsigned bits, ClangTypeInfo clangTypeInfo, Type globalActor,
597- Type thrownError)
598- : builder(bits, clangTypeInfo, globalActor, thrownError) {
614+ Type thrownError, LifetimeDependenceInfo lifetimeDependenceInfo)
615+ : builder(bits, clangTypeInfo, globalActor, thrownError,
616+ lifetimeDependenceInfo) {
599617 builder.checkInvariants ();
600618 };
601619
@@ -642,6 +660,10 @@ class ASTExtInfo {
642660 Type getGlobalActor () const { return builder.getGlobalActor (); }
643661 Type getThrownError () const { return builder.getThrownError (); }
644662
663+ LifetimeDependenceInfo getLifetimeDependenceInfo () const {
664+ return builder.getLifetimeDependenceInfo ();
665+ }
666+
645667 // / Helper method for changing the representation.
646668 // /
647669 // / Prefer using \c ASTExtInfoBuilder::withRepresentation for chaining.
@@ -695,6 +717,11 @@ class ASTExtInfo {
695717 return builder.withGlobalActor (globalActor).build ();
696718 }
697719
720+ [[nodiscard]] ASTExtInfo withLifetimeDependenceInfo (
721+ LifetimeDependenceInfo lifetimeDependenceInfo) const {
722+ return builder.withLifetimeDependenceInfo (lifetimeDependenceInfo).build ();
723+ }
724+
698725 bool isEqualTo (ASTExtInfo other, bool useClangTypes) const {
699726 return builder.isEqualTo (other.builder , useClangTypes);
700727 }
0 commit comments