@@ -390,42 +390,47 @@ class ASTExtInfoBuilder {
390
390
unsigned bits; // Naturally sized for speed.
391
391
392
392
ClangTypeInfo clangTypeInfo;
393
+
393
394
Type globalActor;
394
395
Type thrownError;
395
396
397
+ LifetimeDependenceInfo lifetimeDependenceInfo;
398
+
396
399
using Representation = FunctionTypeRepresentation;
397
400
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) {}
403
407
404
408
public:
405
409
// / An ExtInfoBuilder for a typical Swift function: @convention(swift),
406
410
// / @escaping, non-throwing, non-differentiable.
407
411
ASTExtInfoBuilder ()
408
412
: ASTExtInfoBuilder(Representation::Swift, false , false , Type(),
409
413
DifferentiabilityKind::NonDifferentiable, nullptr,
410
- Type()) {}
414
+ Type(), LifetimeDependenceInfo() ) {}
411
415
412
416
// Constructor for polymorphic type.
413
417
ASTExtInfoBuilder (Representation rep, bool throws, Type thrownError)
414
418
: ASTExtInfoBuilder(rep, false , throws, thrownError,
415
419
DifferentiabilityKind::NonDifferentiable, nullptr ,
416
- Type ()) {}
420
+ Type (), LifetimeDependenceInfo() ) {}
417
421
418
422
// Constructor with no defaults.
419
423
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 )
423
427
: ASTExtInfoBuilder(
424
428
((unsigned )rep) | (isNoEscape ? NoEscapeMask : 0 ) |
425
429
(throws ? ThrowsMask : 0 ) |
426
430
(((unsigned )diffKind << DifferentiabilityMaskOffset) &
427
431
DifferentiabilityMask),
428
- ClangTypeInfo(type), globalActor, thrownError) {}
432
+ ClangTypeInfo(type), globalActor, thrownError,
433
+ lifetimeDependenceInfo) {}
429
434
430
435
void checkInvariants () const ;
431
436
@@ -465,6 +470,10 @@ class ASTExtInfoBuilder {
465
470
Type getGlobalActor () const { return globalActor; }
466
471
Type getThrownError () const { return thrownError; }
467
472
473
+ LifetimeDependenceInfo getLifetimeDependenceInfo () const {
474
+ return lifetimeDependenceInfo;
475
+ }
476
+
468
477
constexpr bool hasSelfParam () const {
469
478
switch (getSILRepresentation ()) {
470
479
case SILFunctionTypeRepresentation::Thick:
@@ -498,31 +507,31 @@ class ASTExtInfoBuilder {
498
507
return ASTExtInfoBuilder ((bits & ~RepresentationMask) | (unsigned )rep,
499
508
shouldStoreClangType (rep) ? clangTypeInfo
500
509
: ClangTypeInfo (),
501
- globalActor, thrownError);
510
+ globalActor, thrownError, lifetimeDependenceInfo );
502
511
}
503
512
[[nodiscard]]
504
513
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 );
508
517
}
509
518
[[nodiscard]]
510
519
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 );
514
523
}
515
524
[[nodiscard]]
516
525
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 );
520
529
}
521
530
[[nodiscard]]
522
531
ASTExtInfoBuilder withThrows (bool throws, Type thrownError) const {
523
532
return ASTExtInfoBuilder (
524
533
throws ? (bits | ThrowsMask) : (bits & ~ThrowsMask), clangTypeInfo,
525
- globalActor, thrownError);
534
+ globalActor, thrownError, lifetimeDependenceInfo );
526
535
}
527
536
[[nodiscard]]
528
537
ASTExtInfoBuilder withThrows () const {
@@ -534,12 +543,12 @@ class ASTExtInfoBuilder {
534
543
return ASTExtInfoBuilder (
535
544
(bits & ~DifferentiabilityMask) |
536
545
((unsigned )differentiability << DifferentiabilityMaskOffset),
537
- clangTypeInfo, globalActor, thrownError);
546
+ clangTypeInfo, globalActor, thrownError, lifetimeDependenceInfo );
538
547
}
539
548
[[nodiscard]]
540
549
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 );
543
552
}
544
553
545
554
// / Put a SIL representation in the ExtInfo.
@@ -553,19 +562,27 @@ class ASTExtInfoBuilder {
553
562
return ASTExtInfoBuilder ((bits & ~RepresentationMask) | (unsigned )rep,
554
563
shouldStoreClangType (rep) ? clangTypeInfo
555
564
: ClangTypeInfo (),
556
- globalActor, thrownError);
565
+ globalActor, thrownError, lifetimeDependenceInfo );
557
566
}
558
567
559
568
[[nodiscard]]
560
569
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);
562
578
}
563
579
564
580
bool isEqualTo (ASTExtInfoBuilder other, bool useClangTypes) const {
565
581
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 ;
569
586
}
570
587
571
588
constexpr std::tuple<unsigned , const void *, const void *, const void *>
@@ -594,8 +611,9 @@ class ASTExtInfo {
594
611
ASTExtInfo (ASTExtInfoBuilder builder) : builder(builder) {}
595
612
596
613
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) {
599
617
builder.checkInvariants ();
600
618
};
601
619
@@ -642,6 +660,10 @@ class ASTExtInfo {
642
660
Type getGlobalActor () const { return builder.getGlobalActor (); }
643
661
Type getThrownError () const { return builder.getThrownError (); }
644
662
663
+ LifetimeDependenceInfo getLifetimeDependenceInfo () const {
664
+ return builder.getLifetimeDependenceInfo ();
665
+ }
666
+
645
667
// / Helper method for changing the representation.
646
668
// /
647
669
// / Prefer using \c ASTExtInfoBuilder::withRepresentation for chaining.
@@ -695,6 +717,11 @@ class ASTExtInfo {
695
717
return builder.withGlobalActor (globalActor).build ();
696
718
}
697
719
720
+ [[nodiscard]] ASTExtInfo withLifetimeDependenceInfo (
721
+ LifetimeDependenceInfo lifetimeDependenceInfo) const {
722
+ return builder.withLifetimeDependenceInfo (lifetimeDependenceInfo).build ();
723
+ }
724
+
698
725
bool isEqualTo (ASTExtInfo other, bool useClangTypes) const {
699
726
return builder.isEqualTo (other.builder , useClangTypes);
700
727
}
0 commit comments