@@ -379,8 +379,7 @@ DeclAttributes::isUnavailableInSwiftVersion(
379
379
if (available->isInvalid ())
380
380
continue ;
381
381
382
- if (available->getPlatformAgnosticAvailability () ==
383
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific) {
382
+ if (available->isLanguageVersionSpecific ()) {
384
383
if (available->Introduced .has_value () &&
385
384
available->Introduced .value () > vers)
386
385
return true ;
@@ -413,13 +412,14 @@ DeclAttributes::findMostSpecificActivePlatform(const ASTContext &ctx,
413
412
if (!avAttr->isActivePlatform (ctx))
414
413
continue ;
415
414
416
- if (ignoreAppExtensions && isApplicationExtensionPlatform (avAttr->Platform ))
415
+ if (ignoreAppExtensions &&
416
+ isApplicationExtensionPlatform (avAttr->getPlatform ()))
417
417
continue ;
418
418
419
419
// We have an attribute that is active for the platform, but
420
420
// is it more specific than our current best?
421
- if (!bestAttr || inheritsAvailabilityFromPlatform (avAttr-> Platform ,
422
- bestAttr->Platform )) {
421
+ if (!bestAttr || inheritsAvailabilityFromPlatform (
422
+ avAttr-> getPlatform (), bestAttr->getPlatform () )) {
423
423
bestAttr = avAttr;
424
424
}
425
425
}
@@ -452,7 +452,7 @@ DeclAttributes::getUnavailable(const ASTContext &ctx,
452
452
continue ;
453
453
454
454
if (ignoreAppExtensions &&
455
- isApplicationExtensionPlatform (AvAttr->Platform ))
455
+ isApplicationExtensionPlatform (AvAttr->getPlatform () ))
456
456
continue ;
457
457
458
458
// Unconditional unavailable.
@@ -582,8 +582,8 @@ const AvailableAttr *DeclAttributes::getNoAsync(const ASTContext &ctx) const {
582
582
bestAttr = avAttr;
583
583
} else if (bestAttr && avAttr->hasPlatform () &&
584
584
bestAttr->hasPlatform () &&
585
- inheritsAvailabilityFromPlatform (avAttr->Platform ,
586
- bestAttr->Platform )) {
585
+ inheritsAvailabilityFromPlatform (avAttr->getPlatform () ,
586
+ bestAttr->getPlatform () )) {
587
587
// if they both have a viable platform, use the better one
588
588
bestAttr = avAttr;
589
589
} else if (avAttr->hasPlatform () && !bestAttr->hasPlatform ()) {
@@ -655,7 +655,7 @@ static bool isShortAvailable(const DeclAttribute *DA) {
655
655
if (!AvailAttr->Rename .empty ())
656
656
return false ;
657
657
658
- switch (AvailAttr->PlatformAgnostic ) {
658
+ switch (AvailAttr->getPlatformAgnosticAvailability () ) {
659
659
case PlatformAgnosticAvailabilityKind::Deprecated:
660
660
case PlatformAgnosticAvailabilityKind::Unavailable:
661
661
case PlatformAgnosticAvailabilityKind::UnavailableInSwift:
@@ -682,10 +682,11 @@ static bool isShortFormAvailabilityImpliedByOther(const AvailableAttr *Attr,
682
682
683
683
for (auto *DA : Others) {
684
684
auto *Other = cast<AvailableAttr>(DA);
685
- if (Attr->Platform == Other->Platform )
685
+ if (Attr->getPlatform () == Other->getPlatform () )
686
686
continue ;
687
687
688
- if (!inheritsAvailabilityFromPlatform (Attr->Platform , Other->Platform ))
688
+ if (!inheritsAvailabilityFromPlatform (Attr->getPlatform (),
689
+ Other->getPlatform ()))
689
690
continue ;
690
691
691
692
if (Attr->Introduced == Other->Introduced )
@@ -730,7 +731,7 @@ static void printShortFormAvailable(ArrayRef<const DeclAttribute *> Attrs,
730
731
if (!Options.IsForSwiftInterface &&
731
732
isShortFormAvailabilityImpliedByOther (AvailAttr, Attrs))
732
733
continue ;
733
- Printer << platformString (AvailAttr->Platform ) << " "
734
+ Printer << platformString (AvailAttr->getPlatform () ) << " "
734
735
<< AvailAttr->Introduced .value ().getAsString () << " , " ;
735
736
}
736
737
Printer << " *" ;
@@ -959,7 +960,7 @@ static std::optional<PlatformKind>
959
960
referencedPlatform (const DeclAttribute *attr) {
960
961
switch (attr->getKind ()) {
961
962
case DeclAttrKind::Available:
962
- return static_cast <const AvailableAttr *>(attr)->Platform ;
963
+ return static_cast <const AvailableAttr *>(attr)->getPlatform () ;
963
964
case DeclAttrKind::BackDeployed:
964
965
return static_cast <const BackDeployedAttr *>(attr)->Platform ;
965
966
case DeclAttrKind::OriginallyDefinedIn:
@@ -2232,15 +2233,16 @@ AvailableAttr::AvailableAttr(
2232
2233
Message(Message), Rename(Rename), RenameDecl(RenameDecl),
2233
2234
INIT_VER_TUPLE(Introduced), IntroducedRange(IntroducedRange),
2234
2235
INIT_VER_TUPLE(Deprecated), DeprecatedRange(DeprecatedRange),
2235
- INIT_VER_TUPLE(Obsoleted), ObsoletedRange(ObsoletedRange),
2236
- PlatformAgnostic(PlatformAgnostic), Platform(Platform) {
2236
+ INIT_VER_TUPLE(Obsoleted), ObsoletedRange(ObsoletedRange) {
2237
+ Bits.AvailableAttr .Platform = static_cast <uint8_t >(Platform);
2238
+ Bits.AvailableAttr .PlatformAgnostic = static_cast <uint8_t >(PlatformAgnostic);
2237
2239
Bits.AvailableAttr .IsSPI = IsSPI;
2238
2240
2239
2241
if (IsForEmbedded) {
2240
2242
// FIXME: The IsForEmbedded bit should be removed when library availability
2241
2243
// conditions are implemented (rdar://138802876)
2242
2244
Bits.AvailableAttr .IsForEmbedded = true ;
2243
- assert (Platform == PlatformKind::none);
2245
+ assert (getPlatform () == PlatformKind::none);
2244
2246
}
2245
2247
}
2246
2248
@@ -2277,7 +2279,7 @@ AvailableAttr *AvailableAttr::createForAlternative(
2277
2279
}
2278
2280
2279
2281
bool AvailableAttr::isActivePlatform (const ASTContext &ctx) const {
2280
- return isPlatformActive (Platform , ctx.LangOpts );
2282
+ return isPlatformActive (getPlatform () , ctx.LangOpts );
2281
2283
}
2282
2284
2283
2285
bool BackDeployedAttr::isActivePlatform (const ASTContext &ctx,
@@ -2288,14 +2290,14 @@ bool BackDeployedAttr::isActivePlatform(const ASTContext &ctx,
2288
2290
AvailableAttr *AvailableAttr::clone (ASTContext &C, bool implicit) const {
2289
2291
return new (C) AvailableAttr (implicit ? SourceLoc () : AtLoc,
2290
2292
implicit ? SourceRange () : getRange (),
2291
- Platform , Message, Rename, RenameDecl,
2293
+ getPlatform () , Message, Rename, RenameDecl,
2292
2294
Introduced ? *Introduced : llvm::VersionTuple (),
2293
2295
implicit ? SourceRange () : IntroducedRange,
2294
2296
Deprecated ? *Deprecated : llvm::VersionTuple (),
2295
2297
implicit ? SourceRange () : DeprecatedRange,
2296
2298
Obsoleted ? *Obsoleted : llvm::VersionTuple (),
2297
2299
implicit ? SourceRange () : ObsoletedRange,
2298
- PlatformAgnostic ,
2300
+ getPlatformAgnosticAvailability () ,
2299
2301
implicit,
2300
2302
isSPI (),
2301
2303
isForEmbedded ());
@@ -2330,10 +2332,10 @@ OriginallyDefinedInAttr *OriginallyDefinedInAttr::clone(ASTContext &C,
2330
2332
}
2331
2333
2332
2334
bool AvailableAttr::isLanguageVersionSpecific () const {
2333
- if (PlatformAgnostic ==
2335
+ if (getPlatformAgnosticAvailability () ==
2334
2336
PlatformAgnosticAvailabilityKind::SwiftVersionSpecific)
2335
2337
{
2336
- assert (Platform == PlatformKind::none &&
2338
+ assert (getPlatform () == PlatformKind::none &&
2337
2339
(Introduced.has_value () ||
2338
2340
Deprecated.has_value () ||
2339
2341
Obsoleted.has_value ()));
@@ -2343,10 +2345,10 @@ bool AvailableAttr::isLanguageVersionSpecific() const {
2343
2345
}
2344
2346
2345
2347
bool AvailableAttr::isPackageDescriptionVersionSpecific () const {
2346
- if (PlatformAgnostic ==
2348
+ if (getPlatformAgnosticAvailability () ==
2347
2349
PlatformAgnosticAvailabilityKind::PackageDescriptionVersionSpecific)
2348
2350
{
2349
- assert (Platform == PlatformKind::none &&
2351
+ assert (getPlatform () == PlatformKind::none &&
2350
2352
(Introduced.has_value () ||
2351
2353
Deprecated.has_value () ||
2352
2354
Obsoleted.has_value ()));
@@ -2356,7 +2358,7 @@ bool AvailableAttr::isPackageDescriptionVersionSpecific() const {
2356
2358
}
2357
2359
2358
2360
bool AvailableAttr::isUnconditionallyUnavailable () const {
2359
- switch (PlatformAgnostic ) {
2361
+ switch (getPlatformAgnosticAvailability () ) {
2360
2362
case PlatformAgnosticAvailabilityKind::None:
2361
2363
case PlatformAgnosticAvailabilityKind::Deprecated:
2362
2364
case PlatformAgnosticAvailabilityKind::SwiftVersionSpecific:
@@ -2373,7 +2375,7 @@ bool AvailableAttr::isUnconditionallyUnavailable() const {
2373
2375
}
2374
2376
2375
2377
bool AvailableAttr::isUnconditionallyDeprecated () const {
2376
- switch (PlatformAgnostic ) {
2378
+ switch (getPlatformAgnosticAvailability () ) {
2377
2379
case PlatformAgnosticAvailabilityKind::None:
2378
2380
case PlatformAgnosticAvailabilityKind::Unavailable:
2379
2381
case PlatformAgnosticAvailabilityKind::UnavailableInSwift:
@@ -2390,7 +2392,8 @@ bool AvailableAttr::isUnconditionallyDeprecated() const {
2390
2392
}
2391
2393
2392
2394
bool AvailableAttr::isNoAsync () const {
2393
- return PlatformAgnostic == PlatformAgnosticAvailabilityKind::NoAsync;
2395
+ return getPlatformAgnosticAvailability () ==
2396
+ PlatformAgnosticAvailabilityKind::NoAsync;
2394
2397
}
2395
2398
2396
2399
llvm::VersionTuple AvailableAttr::getActiveVersion (const ASTContext &ctx) const {
0 commit comments