@@ -554,18 +554,9 @@ static void applyAvailableAttribute(Decl *decl, AvailabilityRange &info,
554
554
if (info.isAlwaysAvailable ())
555
555
return ;
556
556
557
- llvm::VersionTuple noVersion;
558
- auto AvAttr = new (C) AvailableAttr (
559
- SourceLoc (), SourceRange (), targetPlatform (C.LangOpts ),
560
- /* Message=*/ StringRef (),
561
- /* Rename=*/ StringRef (), info.getRawMinimumVersion (),
562
- /* IntroducedRange=*/ SourceRange (),
563
- /* Deprecated=*/ noVersion,
564
- /* DeprecatedRange=*/ SourceRange (),
565
- /* Obsoleted=*/ noVersion,
566
- /* ObsoletedRange=*/ SourceRange (), PlatformAgnosticAvailabilityKind::None,
567
- /* Implicit=*/ false ,
568
- /* SPI=*/ false );
557
+ auto AvAttr = AvailableAttr::createPlatformVersioned (
558
+ C, targetPlatform (C.LangOpts ), /* Message=*/ " " , /* Rename=*/ " " ,
559
+ info.getRawMinimumVersion (), /* Deprecated=*/ {}, /* Obsoleted=*/ {});
569
560
570
561
decl->getAttrs ().add (AvAttr);
571
562
}
@@ -1304,9 +1295,8 @@ namespace {
1304
1295
// "Raw" is the Objective-C name, which was never available in Swift.
1305
1296
// Variants within the active version are usually declarations that
1306
1297
// have been superseded, like the accessors of a property.
1307
- attr = AvailableAttr::createPlatformAgnostic (
1308
- ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1309
- PlatformAgnosticAvailabilityKind::UnavailableInSwift);
1298
+ attr = AvailableAttr::createUnavailableInSwift (
1299
+ ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()));
1310
1300
} else {
1311
1301
unsigned majorVersion = getVersion ().majorVersionNumber ();
1312
1302
unsigned minorVersion = getVersion ().minorVersionNumber ();
@@ -1319,26 +1309,19 @@ namespace {
1319
1309
(majorVersion == 4 && minorVersion < 2 )
1320
1310
? llvm::VersionTuple (4 , 2 )
1321
1311
: llvm::VersionTuple (majorVersion + 1 );
1322
- attr = AvailableAttr::createPlatformAgnostic (
1323
- ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1324
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
1325
- obsoletedVersion);
1312
+ attr = AvailableAttr::createSwiftLanguageModeVersioned (
1313
+ ctx, /* Message=*/ " " , ctx.AllocateCopy (renamed.str ()),
1314
+ /* Introduced=*/ {}, obsoletedVersion);
1326
1315
} else {
1327
1316
// Future names are introduced in their future version.
1328
1317
assert (getVersion () > getActiveSwiftVersion ());
1329
1318
llvm::VersionTuple introducedVersion =
1330
1319
(majorVersion == 4 && minorVersion == 2 )
1331
1320
? llvm::VersionTuple (4 , 2 )
1332
1321
: llvm::VersionTuple (majorVersion);
1333
- attr = new (ctx) AvailableAttr (
1334
- SourceLoc (), SourceRange (), PlatformKind::none,
1335
- /* Message=*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1336
- /* Introduced=*/ introducedVersion, SourceRange (),
1337
- /* Deprecated=*/ llvm::VersionTuple (), SourceRange (),
1338
- /* Obsoleted=*/ llvm::VersionTuple (), SourceRange (),
1339
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
1340
- /* Implicit=*/ false ,
1341
- /* SPI=*/ false );
1322
+ attr = AvailableAttr::createSwiftLanguageModeVersioned (
1323
+ ctx, /* Message=*/ " " , ctx.AllocateCopy (renamed.str ()),
1324
+ introducedVersion, /* Obsoleted=*/ {});
1342
1325
}
1343
1326
}
1344
1327
@@ -1525,10 +1508,8 @@ namespace {
1525
1508
1526
1509
// Make Objective-C's 'id' unavailable.
1527
1510
if (Impl.SwiftContext .LangOpts .EnableObjCInterop && isObjCId (Decl)) {
1528
- auto attr = AvailableAttr::createPlatformAgnostic (
1529
- Impl.SwiftContext ,
1530
- " 'id' is not available in Swift; use 'Any'" , " " ,
1531
- PlatformAgnosticAvailabilityKind::UnavailableInSwift);
1511
+ auto attr = AvailableAttr::createUnavailableInSwift (
1512
+ Impl.SwiftContext , " 'id' is not available in Swift; use 'Any'" , " " );
1532
1513
Result->getAttrs ().add (attr);
1533
1514
}
1534
1515
@@ -2391,12 +2372,12 @@ namespace {
2391
2372
synthesizer.createDefaultConstructor (result);
2392
2373
ctors.push_back (defaultCtor);
2393
2374
if (cxxRecordDecl) {
2394
- auto attr = AvailableAttr::createPlatformAgnostic (
2375
+ auto attr = AvailableAttr::createUniversallyDeprecated (
2395
2376
defaultCtor->getASTContext (),
2396
2377
" This zero-initializes the backing memory of the struct, which "
2397
2378
" is unsafe for some C++ structs. Consider adding an explicit "
2398
2379
" default initializer for this C++ struct." ,
2399
- " " , PlatformAgnosticAvailabilityKind::Deprecated );
2380
+ " " );
2400
2381
defaultCtor->getAttrs ().add (attr);
2401
2382
}
2402
2383
}
@@ -2910,16 +2891,11 @@ namespace {
2910
2891
auto availability = Impl.SwiftContext .getSwift58Availability ();
2911
2892
if (!availability.isAlwaysAvailable ()) {
2912
2893
assert (availability.hasMinimumVersion ());
2913
- auto AvAttr = new (Impl.SwiftContext )
2914
- AvailableAttr (SourceLoc (), SourceRange (),
2915
- targetPlatform (Impl.SwiftContext .LangOpts ),
2916
- /* Message=*/ " " , /* Rename=*/ " " ,
2917
- availability.getRawMinimumVersion (),
2918
- /* IntroducedRange=*/ SourceRange (), {},
2919
- /* DeprecatedRange=*/ SourceRange (), {},
2920
- /* ObsoletedRange=*/ SourceRange (),
2921
- PlatformAgnosticAvailabilityKind::None,
2922
- /* Implicit=*/ false , false );
2894
+ auto AvAttr = AvailableAttr::createPlatformVersioned (
2895
+ Impl.SwiftContext , targetPlatform (Impl.SwiftContext .LangOpts ),
2896
+ /* Message=*/ " " , /* Rename=*/ " " ,
2897
+ availability.getRawMinimumVersion (), /* Deprecated=*/ {},
2898
+ /* Obsoleted=*/ {});
2923
2899
classDecl->getAttrs ().add (AvAttr);
2924
2900
}
2925
2901
}
@@ -4419,7 +4395,7 @@ namespace {
4419
4395
decl, AccessLevel::Public, loc, name, loc, std::nullopt,
4420
4396
genericParamList, dc);
4421
4397
4422
- auto attr = AvailableAttr::createPlatformAgnostic (
4398
+ auto attr = AvailableAttr::createUniversallyUnavailable (
4423
4399
Impl.SwiftContext , " Un-specialized class templates are not currently "
4424
4400
" supported. Please use a specialization of this "
4425
4401
" type." );
@@ -5389,8 +5365,8 @@ namespace {
5389
5365
message = " cannot find Swift declaration for this protocol" ;
5390
5366
else
5391
5367
llvm_unreachable (" unknown bridged decl kind" );
5392
- auto attr = AvailableAttr::createPlatformAgnostic (Impl.SwiftContext ,
5393
- message);
5368
+ auto attr = AvailableAttr::createUniversallyUnavailable (Impl.SwiftContext ,
5369
+ message);
5394
5370
VD->getAttrs ().add (attr);
5395
5371
}
5396
5372
@@ -5443,7 +5419,7 @@ namespace {
5443
5419
addObjCAttribute (result,
5444
5420
Impl.importIdentifier (decl->getIdentifier ()));
5445
5421
result->setImplicit ();
5446
- auto attr = AvailableAttr::createPlatformAgnostic (
5422
+ auto attr = AvailableAttr::createUniversallyUnavailable (
5447
5423
Impl.SwiftContext ,
5448
5424
" This Objective-C protocol has only been forward-declared; "
5449
5425
" import its owning module to use it" );
@@ -5598,7 +5574,8 @@ namespace {
5598
5574
auto result = createFakeClass (name, /* cacheResult */ true ,
5599
5575
/* inheritFromNSObject */ true );
5600
5576
result->setImplicit ();
5601
- auto attr = AvailableAttr::createPlatformAgnostic (Impl.SwiftContext ,
5577
+ auto attr = AvailableAttr::createUniversallyUnavailable (
5578
+ Impl.SwiftContext ,
5602
5579
" This Objective-C class has only been forward-declared; "
5603
5580
" import its owning module to use it" );
5604
5581
result->getAttrs ().add (attr);
@@ -6490,7 +6467,7 @@ SwiftDeclConverter::importOptionConstant(const clang::EnumConstantDecl *decl,
6490
6467
!CD->isUnavailable ()) {
6491
6468
// / Create an AvailableAttr that indicates specific availability
6492
6469
// / for all platforms.
6493
- auto attr = AvailableAttr::createPlatformAgnostic (
6470
+ auto attr = AvailableAttr::createUniversallyUnavailable (
6494
6471
Impl.SwiftContext , " use [] to construct an empty option set" );
6495
6472
CD->getAttrs ().add (attr);
6496
6473
}
@@ -7127,7 +7104,7 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
7127
7104
errorStr += objcMethod->getSelector ().getAsString ();
7128
7105
errorStr += ' ]' ;
7129
7106
7130
- auto attr = AvailableAttr::createPlatformAgnostic (
7107
+ auto attr = AvailableAttr::createUniversallyUnavailable (
7131
7108
Impl.SwiftContext , Impl.SwiftContext .AllocateCopy (errorStr.str ()));
7132
7109
ctor->getAttrs ().add (attr);
7133
7110
continue ;
@@ -8808,7 +8785,7 @@ void ClangImporter::Implementation::importAttributes(
8808
8785
//
8809
8786
if (auto unavailable = dyn_cast<clang::UnavailableAttr>(*AI)) {
8810
8787
auto Message = unavailable->getMessage ();
8811
- auto attr = AvailableAttr::createPlatformAgnostic (C, Message);
8788
+ auto attr = AvailableAttr::createUniversallyUnavailable (C, Message);
8812
8789
MappedDecl->getAttrs ().add (attr);
8813
8790
AnyUnavailable = true ;
8814
8791
continue ;
@@ -8821,8 +8798,7 @@ void ClangImporter::Implementation::importAttributes(
8821
8798
//
8822
8799
if (auto unavailable_annot = dyn_cast<clang::AnnotateAttr>(*AI))
8823
8800
if (unavailable_annot->getAnnotation () == " swift1_unavailable" ) {
8824
- auto attr = AvailableAttr::createPlatformAgnostic (
8825
- C, " " , " " , PlatformAgnosticAvailabilityKind::UnavailableInSwift);
8801
+ auto attr = AvailableAttr::createUnavailableInSwift (C, " " , " " );
8826
8802
MappedDecl->getAttrs ().add (attr);
8827
8803
AnyUnavailable = true ;
8828
8804
continue ;
@@ -8835,8 +8811,7 @@ void ClangImporter::Implementation::importAttributes(
8835
8811
//
8836
8812
if (auto deprecated = dyn_cast<clang::DeprecatedAttr>(*AI)) {
8837
8813
auto Message = deprecated->getMessage ();
8838
- auto attr = AvailableAttr::createPlatformAgnostic (C, Message, " " ,
8839
- PlatformAgnosticAvailabilityKind::Deprecated);
8814
+ auto attr = AvailableAttr::createUniversallyDeprecated (C, Message, " " );
8840
8815
MappedDecl->getAttrs ().add (attr);
8841
8816
continue ;
8842
8817
}
@@ -8858,9 +8833,8 @@ void ClangImporter::Implementation::importAttributes(
8858
8833
if (!replacement.empty ())
8859
8834
swiftReplacement = getSwiftNameFromClangName (replacement);
8860
8835
8861
- auto attr = AvailableAttr::createPlatformAgnostic (
8862
- C, avail->getMessage (), swiftReplacement,
8863
- PlatformAgnosticAvailabilityKind::UnavailableInSwift);
8836
+ auto attr = AvailableAttr::createUnavailableInSwift (
8837
+ C, avail->getMessage (), swiftReplacement);
8864
8838
MappedDecl->getAttrs ().add (attr);
8865
8839
AnyUnavailable = true ;
8866
8840
continue ;
@@ -8968,7 +8942,7 @@ void ClangImporter::Implementation::importAttributes(
8968
8942
if (auto ID = dyn_cast<clang::ObjCInterfaceDecl>(ClangDecl)) {
8969
8943
// Ban NSInvocation.
8970
8944
if (ID->getName () == " NSInvocation" ) {
8971
- auto attr = AvailableAttr::createPlatformAgnostic (C, " " );
8945
+ auto attr = AvailableAttr::createUniversallyUnavailable (C, " " );
8972
8946
MappedDecl->getAttrs ().add (attr);
8973
8947
return ;
8974
8948
}
@@ -9001,8 +8975,8 @@ void ClangImporter::Implementation::importAttributes(
9001
8975
!FD->getAttr <clang::SwiftNameAttr>()) {
9002
8976
if (auto t = FD->getParamDecl (0 )->getType ()->getAs <clang::TypedefType>()){
9003
8977
if (isCFTypeDecl (t->getDecl ())) {
9004
- auto attr = AvailableAttr::createPlatformAgnostic (C,
9005
- " Core Foundation objects are automatically memory managed" );
8978
+ auto attr = AvailableAttr::createUniversallyUnavailable (
8979
+ C, " Core Foundation objects are automatically memory managed" );
9006
8980
MappedDecl->getAttrs ().add (attr);
9007
8981
return ;
9008
8982
}
@@ -9690,8 +9664,8 @@ void ClangImporter::Implementation::
9690
9664
markUnavailable (ValueDecl *decl, StringRef unavailabilityMsgRef) {
9691
9665
9692
9666
unavailabilityMsgRef = SwiftContext.AllocateCopy (unavailabilityMsgRef);
9693
- auto ua = AvailableAttr::createPlatformAgnostic (SwiftContext,
9694
- unavailabilityMsgRef);
9667
+ auto ua = AvailableAttr::createUniversallyUnavailable (SwiftContext,
9668
+ unavailabilityMsgRef);
9695
9669
decl->getAttrs ().add (ua);
9696
9670
}
9697
9671
0 commit comments