@@ -309,33 +309,38 @@ class ASTExtInfoBuilder {
309
309
unsigned bits; // Naturally sized for speed.
310
310
311
311
ClangTypeInfo clangTypeInfo;
312
+ Type globalActor;
312
313
313
314
using Representation = FunctionTypeRepresentation;
314
315
315
- ASTExtInfoBuilder (unsigned bits, ClangTypeInfo clangTypeInfo)
316
- : bits(bits), clangTypeInfo(clangTypeInfo) {}
316
+ ASTExtInfoBuilder (
317
+ unsigned bits, ClangTypeInfo clangTypeInfo, Type globalActor
318
+ ) : bits(bits), clangTypeInfo(clangTypeInfo), globalActor(globalActor) {}
317
319
318
320
public:
319
321
// / An ExtInfoBuilder for a typical Swift function: @convention(swift),
320
322
// / @escaping, non-throwing, non-differentiable.
321
323
ASTExtInfoBuilder ()
322
324
: ASTExtInfoBuilder(Representation::Swift, false , false ,
323
- DifferentiabilityKind::NonDifferentiable, nullptr ) {}
325
+ DifferentiabilityKind::NonDifferentiable, nullptr ,
326
+ Type ()) {}
324
327
325
328
// Constructor for polymorphic type.
326
329
ASTExtInfoBuilder (Representation rep, bool throws)
327
330
: ASTExtInfoBuilder(rep, false , throws,
328
- DifferentiabilityKind::NonDifferentiable, nullptr ) {}
331
+ DifferentiabilityKind::NonDifferentiable, nullptr ,
332
+ Type ()) {}
329
333
330
334
// Constructor with no defaults.
331
335
ASTExtInfoBuilder (Representation rep, bool isNoEscape, bool throws,
332
- DifferentiabilityKind diffKind, const clang::Type *type)
336
+ DifferentiabilityKind diffKind, const clang::Type *type,
337
+ Type globalActor)
333
338
: ASTExtInfoBuilder(
334
339
((unsigned )rep) | (isNoEscape ? NoEscapeMask : 0 ) |
335
340
(throws ? ThrowsMask : 0 ) |
336
341
(((unsigned )diffKind << DifferentiabilityMaskOffset) &
337
342
DifferentiabilityMask),
338
- ClangTypeInfo (type)) {}
343
+ ClangTypeInfo(type), globalActor ) {}
339
344
340
345
void checkInvariants () const ;
341
346
@@ -374,6 +379,8 @@ class ASTExtInfoBuilder {
374
379
return SILFunctionTypeRepresentation (rawRep);
375
380
}
376
381
382
+ Type getGlobalActor () const { return globalActor; }
383
+
377
384
constexpr bool hasSelfParam () const {
378
385
switch (getSILRepresentation ()) {
379
386
case SILFunctionTypeRepresentation::Thick:
@@ -401,42 +408,44 @@ class ASTExtInfoBuilder {
401
408
ASTExtInfoBuilder withRepresentation (Representation rep) const {
402
409
return ASTExtInfoBuilder ((bits & ~RepresentationMask) | (unsigned )rep,
403
410
shouldStoreClangType (rep) ? clangTypeInfo
404
- : ClangTypeInfo ());
411
+ : ClangTypeInfo (),
412
+ globalActor);
405
413
}
406
414
LLVM_NODISCARD
407
415
ASTExtInfoBuilder withNoEscape (bool noEscape = true ) const {
408
416
return ASTExtInfoBuilder (noEscape ? (bits | NoEscapeMask)
409
417
: (bits & ~NoEscapeMask),
410
- clangTypeInfo);
418
+ clangTypeInfo, globalActor );
411
419
}
412
420
LLVM_NODISCARD
413
421
ASTExtInfoBuilder withConcurrent (bool concurrent = true ) const {
414
422
return ASTExtInfoBuilder (concurrent ? (bits | ConcurrentMask)
415
423
: (bits & ~ConcurrentMask),
416
- clangTypeInfo);
424
+ clangTypeInfo, globalActor );
417
425
}
418
426
LLVM_NODISCARD
419
427
ASTExtInfoBuilder withAsync (bool async = true ) const {
420
428
return ASTExtInfoBuilder (async ? (bits | AsyncMask)
421
429
: (bits & ~AsyncMask),
422
- clangTypeInfo);
430
+ clangTypeInfo, globalActor );
423
431
}
424
432
LLVM_NODISCARD
425
433
ASTExtInfoBuilder withThrows (bool throws = true ) const {
426
434
return ASTExtInfoBuilder (
427
- throws ? (bits | ThrowsMask) : (bits & ~ThrowsMask), clangTypeInfo);
435
+ throws ? (bits | ThrowsMask) : (bits & ~ThrowsMask), clangTypeInfo,
436
+ globalActor);
428
437
}
429
438
LLVM_NODISCARD
430
439
ASTExtInfoBuilder
431
440
withDifferentiabilityKind (DifferentiabilityKind differentiability) const {
432
441
return ASTExtInfoBuilder (
433
442
(bits & ~DifferentiabilityMask) |
434
443
((unsigned )differentiability << DifferentiabilityMaskOffset),
435
- clangTypeInfo);
444
+ clangTypeInfo, globalActor );
436
445
}
437
446
LLVM_NODISCARD
438
447
ASTExtInfoBuilder withClangFunctionType (const clang::Type *type) const {
439
- return ASTExtInfoBuilder (bits, ClangTypeInfo (type));
448
+ return ASTExtInfoBuilder (bits, ClangTypeInfo (type), globalActor );
440
449
}
441
450
442
451
// / Put a SIL representation in the ExtInfo.
@@ -449,16 +458,25 @@ class ASTExtInfoBuilder {
449
458
withSILRepresentation (SILFunctionTypeRepresentation rep) const {
450
459
return ASTExtInfoBuilder ((bits & ~RepresentationMask) | (unsigned )rep,
451
460
shouldStoreClangType (rep) ? clangTypeInfo
452
- : ClangTypeInfo ());
461
+ : ClangTypeInfo (),
462
+ globalActor);
463
+ }
464
+
465
+ LLVM_NODISCARD
466
+ ASTExtInfoBuilder withGlobalActor (Type globalActor) const {
467
+ return ASTExtInfoBuilder (bits, clangTypeInfo, globalActor);
453
468
}
454
469
455
470
bool isEqualTo (ASTExtInfoBuilder other, bool useClangTypes) const {
456
471
return bits == other.bits &&
457
- (useClangTypes ? (clangTypeInfo == other.clangTypeInfo ) : true );
472
+ (useClangTypes ? (clangTypeInfo == other.clangTypeInfo ) : true ) &&
473
+ globalActor.getPointer () == other.globalActor .getPointer ();
458
474
}
459
475
460
- constexpr std::pair<unsigned , const void *> getFuncAttrKey () const {
461
- return std::make_pair (bits, clangTypeInfo.getType ());
476
+ constexpr std::tuple<unsigned , const void *, const void *>
477
+ getFuncAttrKey () const {
478
+ return std::make_tuple (
479
+ bits, clangTypeInfo.getType (), globalActor.getPointer ());
462
480
}
463
481
}; // end ASTExtInfoBuilder
464
482
@@ -479,8 +497,8 @@ class ASTExtInfo {
479
497
// Only for use by ASTExtInfoBuilder::build. Don't use it elsewhere!
480
498
ASTExtInfo (ASTExtInfoBuilder builder) : builder(builder) {}
481
499
482
- ASTExtInfo (unsigned bits, ClangTypeInfo clangTypeInfo)
483
- : builder(bits, clangTypeInfo) {
500
+ ASTExtInfo (unsigned bits, ClangTypeInfo clangTypeInfo, Type globalActor )
501
+ : builder(bits, clangTypeInfo, globalActor ) {
484
502
builder.checkInvariants ();
485
503
};
486
504
@@ -524,6 +542,8 @@ class ASTExtInfo {
524
542
525
543
constexpr bool hasContext () const { return builder.hasContext (); }
526
544
545
+ Type getGlobalActor () const { return builder.getGlobalActor (); }
546
+
527
547
// / Helper method for changing the representation.
528
548
// /
529
549
// / Prefer using \c ASTExtInfoBuilder::withRepresentation for chaining.
@@ -564,11 +584,17 @@ class ASTExtInfo {
564
584
return builder.withAsync (async).build ();
565
585
}
566
586
587
+ LLVM_NODISCARD
588
+ ASTExtInfo withGlobalActor (Type globalActor) const {
589
+ return builder.withGlobalActor (globalActor).build ();
590
+ }
591
+
567
592
bool isEqualTo (ASTExtInfo other, bool useClangTypes) const {
568
593
return builder.isEqualTo (other.builder , useClangTypes);
569
594
}
570
595
571
- constexpr std::pair<unsigned , const void *> getFuncAttrKey () const {
596
+ constexpr std::tuple<unsigned , const void *, const void *>
597
+ getFuncAttrKey () const {
572
598
return builder.getFuncAttrKey ();
573
599
}
574
600
}; // end ASTExtInfo
0 commit comments