@@ -558,18 +558,9 @@ static void applyAvailableAttribute(Decl *decl, AvailabilityRange &info,
558
558
if (info.isAlwaysAvailable ())
559
559
return ;
560
560
561
- llvm::VersionTuple noVersion;
562
- auto AvAttr = new (C) AvailableAttr (
563
- SourceLoc (), SourceRange (), targetPlatform (C.LangOpts ),
564
- /* Message=*/ StringRef (),
565
- /* Rename=*/ StringRef (), info.getRawMinimumVersion (),
566
- /* IntroducedRange=*/ SourceRange (),
567
- /* Deprecated=*/ noVersion,
568
- /* DeprecatedRange=*/ SourceRange (),
569
- /* Obsoleted=*/ noVersion,
570
- /* ObsoletedRange=*/ SourceRange (), PlatformAgnosticAvailabilityKind::None,
571
- /* Implicit=*/ false ,
572
- /* SPI=*/ false );
561
+ auto AvAttr = AvailableAttr::createPlatformVersioned (
562
+ C, targetPlatform (C.LangOpts ), /* Message=*/ " " , /* Rename=*/ " " ,
563
+ info.getRawMinimumVersion (), /* Deprecated=*/ {}, /* Obsoleted=*/ {});
573
564
574
565
decl->getAttrs ().add (AvAttr);
575
566
}
@@ -1308,9 +1299,8 @@ namespace {
1308
1299
// "Raw" is the Objective-C name, which was never available in Swift.
1309
1300
// Variants within the active version are usually declarations that
1310
1301
// have been superseded, like the accessors of a property.
1311
- attr = AvailableAttr::createPlatformAgnostic (
1312
- ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1313
- PlatformAgnosticAvailabilityKind::UnavailableInSwift);
1302
+ attr = AvailableAttr::createUnavailableInSwift (
1303
+ ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()));
1314
1304
} else {
1315
1305
unsigned majorVersion = getVersion ().majorVersionNumber ();
1316
1306
unsigned minorVersion = getVersion ().minorVersionNumber ();
@@ -1323,26 +1313,19 @@ namespace {
1323
1313
(majorVersion == 4 && minorVersion < 2 )
1324
1314
? llvm::VersionTuple (4 , 2 )
1325
1315
: llvm::VersionTuple (majorVersion + 1 );
1326
- attr = AvailableAttr::createPlatformAgnostic (
1327
- ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1328
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
1329
- obsoletedVersion);
1316
+ attr = AvailableAttr::createSwiftLanguageModeVersioned (
1317
+ ctx, /* Message=*/ " " , ctx.AllocateCopy (renamed.str ()),
1318
+ /* Introduced=*/ {}, obsoletedVersion);
1330
1319
} else {
1331
1320
// Future names are introduced in their future version.
1332
1321
assert (getVersion () > getActiveSwiftVersion ());
1333
1322
llvm::VersionTuple introducedVersion =
1334
1323
(majorVersion == 4 && minorVersion == 2 )
1335
1324
? llvm::VersionTuple (4 , 2 )
1336
1325
: llvm::VersionTuple (majorVersion);
1337
- attr = new (ctx) AvailableAttr (
1338
- SourceLoc (), SourceRange (), PlatformKind::none,
1339
- /* Message=*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1340
- /* Introduced=*/ introducedVersion, SourceRange (),
1341
- /* Deprecated=*/ llvm::VersionTuple (), SourceRange (),
1342
- /* Obsoleted=*/ llvm::VersionTuple (), SourceRange (),
1343
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
1344
- /* Implicit=*/ false ,
1345
- /* SPI=*/ false );
1326
+ attr = AvailableAttr::createSwiftLanguageModeVersioned (
1327
+ ctx, /* Message=*/ " " , ctx.AllocateCopy (renamed.str ()),
1328
+ introducedVersion, /* Obsoleted=*/ {});
1346
1329
}
1347
1330
}
1348
1331
@@ -1529,10 +1512,8 @@ namespace {
1529
1512
1530
1513
// Make Objective-C's 'id' unavailable.
1531
1514
if (Impl.SwiftContext .LangOpts .EnableObjCInterop && isObjCId (Decl)) {
1532
- auto attr = AvailableAttr::createPlatformAgnostic (
1533
- Impl.SwiftContext ,
1534
- " 'id' is not available in Swift; use 'Any'" , " " ,
1535
- PlatformAgnosticAvailabilityKind::UnavailableInSwift);
1515
+ auto attr = AvailableAttr::createUnavailableInSwift (
1516
+ Impl.SwiftContext , " 'id' is not available in Swift; use 'Any'" , " " );
1536
1517
Result->getAttrs ().add (attr);
1537
1518
}
1538
1519
@@ -2395,12 +2376,12 @@ namespace {
2395
2376
synthesizer.createDefaultConstructor (result);
2396
2377
ctors.push_back (defaultCtor);
2397
2378
if (cxxRecordDecl) {
2398
- auto attr = AvailableAttr::createPlatformAgnostic (
2379
+ auto attr = AvailableAttr::createUniversallyDeprecated (
2399
2380
defaultCtor->getASTContext (),
2400
2381
" This zero-initializes the backing memory of the struct, which "
2401
2382
" is unsafe for some C++ structs. Consider adding an explicit "
2402
2383
" default initializer for this C++ struct." ,
2403
- " " , PlatformAgnosticAvailabilityKind::Deprecated );
2384
+ " " );
2404
2385
defaultCtor->getAttrs ().add (attr);
2405
2386
}
2406
2387
}
@@ -2914,16 +2895,11 @@ namespace {
2914
2895
auto availability = Impl.SwiftContext .getSwift58Availability ();
2915
2896
if (!availability.isAlwaysAvailable ()) {
2916
2897
assert (availability.hasMinimumVersion ());
2917
- auto AvAttr = new (Impl.SwiftContext )
2918
- AvailableAttr (SourceLoc (), SourceRange (),
2919
- targetPlatform (Impl.SwiftContext .LangOpts ),
2920
- /* Message=*/ " " , /* Rename=*/ " " ,
2921
- availability.getRawMinimumVersion (),
2922
- /* IntroducedRange=*/ SourceRange (), {},
2923
- /* DeprecatedRange=*/ SourceRange (), {},
2924
- /* ObsoletedRange=*/ SourceRange (),
2925
- PlatformAgnosticAvailabilityKind::None,
2926
- /* Implicit=*/ false , false );
2898
+ auto AvAttr = AvailableAttr::createPlatformVersioned (
2899
+ Impl.SwiftContext , targetPlatform (Impl.SwiftContext .LangOpts ),
2900
+ /* Message=*/ " " , /* Rename=*/ " " ,
2901
+ availability.getRawMinimumVersion (), /* Deprecated=*/ {},
2902
+ /* Obsoleted=*/ {});
2927
2903
classDecl->getAttrs ().add (AvAttr);
2928
2904
}
2929
2905
}
@@ -4423,7 +4399,7 @@ namespace {
4423
4399
decl, AccessLevel::Public, loc, name, loc, std::nullopt,
4424
4400
genericParamList, dc);
4425
4401
4426
- auto attr = AvailableAttr::createPlatformAgnostic (
4402
+ auto attr = AvailableAttr::createUniversallyUnavailable (
4427
4403
Impl.SwiftContext , " Un-specialized class templates are not currently "
4428
4404
" supported. Please use a specialization of this "
4429
4405
" type." );
@@ -5393,8 +5369,8 @@ namespace {
5393
5369
message = " cannot find Swift declaration for this protocol" ;
5394
5370
else
5395
5371
llvm_unreachable (" unknown bridged decl kind" );
5396
- auto attr = AvailableAttr::createPlatformAgnostic (Impl.SwiftContext ,
5397
- message);
5372
+ auto attr = AvailableAttr::createUniversallyUnavailable (Impl.SwiftContext ,
5373
+ message);
5398
5374
VD->getAttrs ().add (attr);
5399
5375
}
5400
5376
@@ -5447,7 +5423,7 @@ namespace {
5447
5423
addObjCAttribute (result,
5448
5424
Impl.importIdentifier (decl->getIdentifier ()));
5449
5425
result->setImplicit ();
5450
- auto attr = AvailableAttr::createPlatformAgnostic (
5426
+ auto attr = AvailableAttr::createUniversallyUnavailable (
5451
5427
Impl.SwiftContext ,
5452
5428
" This Objective-C protocol has only been forward-declared; "
5453
5429
" import its owning module to use it" );
@@ -5602,7 +5578,8 @@ namespace {
5602
5578
auto result = createFakeClass (name, /* cacheResult */ true ,
5603
5579
/* inheritFromNSObject */ true );
5604
5580
result->setImplicit ();
5605
- auto attr = AvailableAttr::createPlatformAgnostic (Impl.SwiftContext ,
5581
+ auto attr = AvailableAttr::createUniversallyUnavailable (
5582
+ Impl.SwiftContext ,
5606
5583
" This Objective-C class has only been forward-declared; "
5607
5584
" import its owning module to use it" );
5608
5585
result->getAttrs ().add (attr);
@@ -6494,7 +6471,7 @@ SwiftDeclConverter::importOptionConstant(const clang::EnumConstantDecl *decl,
6494
6471
!CD->isUnavailable ()) {
6495
6472
// / Create an AvailableAttr that indicates specific availability
6496
6473
// / for all platforms.
6497
- auto attr = AvailableAttr::createPlatformAgnostic (
6474
+ auto attr = AvailableAttr::createUniversallyUnavailable (
6498
6475
Impl.SwiftContext , " use [] to construct an empty option set" );
6499
6476
CD->getAttrs ().add (attr);
6500
6477
}
@@ -7131,7 +7108,7 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
7131
7108
errorStr += objcMethod->getSelector ().getAsString ();
7132
7109
errorStr += ' ]' ;
7133
7110
7134
- auto attr = AvailableAttr::createPlatformAgnostic (
7111
+ auto attr = AvailableAttr::createUniversallyUnavailable (
7135
7112
Impl.SwiftContext , Impl.SwiftContext .AllocateCopy (errorStr.str ()));
7136
7113
ctor->getAttrs ().add (attr);
7137
7114
continue ;
@@ -8875,7 +8852,7 @@ void ClangImporter::Implementation::importAttributes(
8875
8852
//
8876
8853
if (auto unavailable = dyn_cast<clang::UnavailableAttr>(*AI)) {
8877
8854
auto Message = unavailable->getMessage ();
8878
- auto attr = AvailableAttr::createPlatformAgnostic (C, Message);
8855
+ auto attr = AvailableAttr::createUniversallyUnavailable (C, Message);
8879
8856
MappedDecl->getAttrs ().add (attr);
8880
8857
AnyUnavailable = true ;
8881
8858
continue ;
@@ -8888,8 +8865,7 @@ void ClangImporter::Implementation::importAttributes(
8888
8865
//
8889
8866
if (auto unavailable_annot = dyn_cast<clang::AnnotateAttr>(*AI))
8890
8867
if (unavailable_annot->getAnnotation () == " swift1_unavailable" ) {
8891
- auto attr = AvailableAttr::createPlatformAgnostic (
8892
- C, " " , " " , PlatformAgnosticAvailabilityKind::UnavailableInSwift);
8868
+ auto attr = AvailableAttr::createUnavailableInSwift (C, " " , " " );
8893
8869
MappedDecl->getAttrs ().add (attr);
8894
8870
AnyUnavailable = true ;
8895
8871
continue ;
@@ -8902,8 +8878,7 @@ void ClangImporter::Implementation::importAttributes(
8902
8878
//
8903
8879
if (auto deprecated = dyn_cast<clang::DeprecatedAttr>(*AI)) {
8904
8880
auto Message = deprecated->getMessage ();
8905
- auto attr = AvailableAttr::createPlatformAgnostic (C, Message, " " ,
8906
- PlatformAgnosticAvailabilityKind::Deprecated);
8881
+ auto attr = AvailableAttr::createUniversallyDeprecated (C, Message, " " );
8907
8882
MappedDecl->getAttrs ().add (attr);
8908
8883
continue ;
8909
8884
}
@@ -8925,9 +8900,8 @@ void ClangImporter::Implementation::importAttributes(
8925
8900
if (!replacement.empty ())
8926
8901
swiftReplacement = getSwiftNameFromClangName (replacement);
8927
8902
8928
- auto attr = AvailableAttr::createPlatformAgnostic (
8929
- C, avail->getMessage (), swiftReplacement,
8930
- PlatformAgnosticAvailabilityKind::UnavailableInSwift);
8903
+ auto attr = AvailableAttr::createUnavailableInSwift (
8904
+ C, avail->getMessage (), swiftReplacement);
8931
8905
MappedDecl->getAttrs ().add (attr);
8932
8906
AnyUnavailable = true ;
8933
8907
continue ;
@@ -9035,7 +9009,7 @@ void ClangImporter::Implementation::importAttributes(
9035
9009
if (auto ID = dyn_cast<clang::ObjCInterfaceDecl>(ClangDecl)) {
9036
9010
// Ban NSInvocation.
9037
9011
if (ID->getName () == " NSInvocation" ) {
9038
- auto attr = AvailableAttr::createPlatformAgnostic (C, " " );
9012
+ auto attr = AvailableAttr::createUniversallyUnavailable (C, " " );
9039
9013
MappedDecl->getAttrs ().add (attr);
9040
9014
return ;
9041
9015
}
@@ -9068,8 +9042,8 @@ void ClangImporter::Implementation::importAttributes(
9068
9042
!FD->getAttr <clang::SwiftNameAttr>()) {
9069
9043
if (auto t = FD->getParamDecl (0 )->getType ()->getAs <clang::TypedefType>()){
9070
9044
if (isCFTypeDecl (t->getDecl ())) {
9071
- auto attr = AvailableAttr::createPlatformAgnostic (C,
9072
- " Core Foundation objects are automatically memory managed" );
9045
+ auto attr = AvailableAttr::createUniversallyUnavailable (
9046
+ C, " Core Foundation objects are automatically memory managed" );
9073
9047
MappedDecl->getAttrs ().add (attr);
9074
9048
return ;
9075
9049
}
@@ -9757,8 +9731,8 @@ void ClangImporter::Implementation::
9757
9731
markUnavailable (ValueDecl *decl, StringRef unavailabilityMsgRef) {
9758
9732
9759
9733
unavailabilityMsgRef = SwiftContext.AllocateCopy (unavailabilityMsgRef);
9760
- auto ua = AvailableAttr::createPlatformAgnostic (SwiftContext,
9761
- unavailabilityMsgRef);
9734
+ auto ua = AvailableAttr::createUniversallyUnavailable (SwiftContext,
9735
+ unavailabilityMsgRef);
9762
9736
decl->getAttrs ().add (ua);
9763
9737
}
9764
9738
0 commit comments