@@ -555,17 +555,9 @@ static void applyAvailableAttribute(Decl *decl, AvailabilityRange &info,
555
555
return ;
556
556
557
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 );
558
+ auto AvAttr = AvailableAttr::createPlatformVersioned (
559
+ C, targetPlatform (C.LangOpts ), /* Message=*/ " " , /* Rename=*/ " " ,
560
+ info.getRawMinimumVersion (), /* Deprecated=*/ {}, /* Obsoleted=*/ {});
569
561
570
562
decl->getAttrs ().add (AvAttr);
571
563
}
@@ -1304,9 +1296,8 @@ namespace {
1304
1296
// "Raw" is the Objective-C name, which was never available in Swift.
1305
1297
// Variants within the active version are usually declarations that
1306
1298
// have been superseded, like the accessors of a property.
1307
- attr = AvailableAttr::createPlatformAgnostic (
1308
- ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1309
- PlatformAgnosticAvailabilityKind::UnavailableInSwift);
1299
+ attr = AvailableAttr::createUnavailableInSwift (
1300
+ ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()));
1310
1301
} else {
1311
1302
unsigned majorVersion = getVersion ().majorVersionNumber ();
1312
1303
unsigned minorVersion = getVersion ().minorVersionNumber ();
@@ -1319,26 +1310,19 @@ namespace {
1319
1310
(majorVersion == 4 && minorVersion < 2 )
1320
1311
? llvm::VersionTuple (4 , 2 )
1321
1312
: llvm::VersionTuple (majorVersion + 1 );
1322
- attr = AvailableAttr::createPlatformAgnostic (
1323
- ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1324
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
1325
- obsoletedVersion);
1313
+ attr = AvailableAttr::createSwiftLanguageModeVersioned (
1314
+ ctx, /* Message=*/ " " , ctx.AllocateCopy (renamed.str ()),
1315
+ /* Introduced=*/ {}, obsoletedVersion);
1326
1316
} else {
1327
1317
// Future names are introduced in their future version.
1328
1318
assert (getVersion () > getActiveSwiftVersion ());
1329
1319
llvm::VersionTuple introducedVersion =
1330
1320
(majorVersion == 4 && minorVersion == 2 )
1331
1321
? llvm::VersionTuple (4 , 2 )
1332
1322
: 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 );
1323
+ attr = AvailableAttr::createSwiftLanguageModeVersioned (
1324
+ ctx, /* Message=*/ " " , ctx.AllocateCopy (renamed.str ()),
1325
+ introducedVersion, /* Obsoleted=*/ {});
1342
1326
}
1343
1327
}
1344
1328
@@ -1525,10 +1509,8 @@ namespace {
1525
1509
1526
1510
// Make Objective-C's 'id' unavailable.
1527
1511
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);
1512
+ auto attr = AvailableAttr::createUnavailableInSwift (
1513
+ Impl.SwiftContext , " 'id' is not available in Swift; use 'Any'" , " " );
1532
1514
Result->getAttrs ().add (attr);
1533
1515
}
1534
1516
@@ -2391,12 +2373,12 @@ namespace {
2391
2373
synthesizer.createDefaultConstructor (result);
2392
2374
ctors.push_back (defaultCtor);
2393
2375
if (cxxRecordDecl) {
2394
- auto attr = AvailableAttr::createPlatformAgnostic (
2376
+ auto attr = AvailableAttr::createUniversallyDeprecated (
2395
2377
defaultCtor->getASTContext (),
2396
2378
" This zero-initializes the backing memory of the struct, which "
2397
2379
" is unsafe for some C++ structs. Consider adding an explicit "
2398
2380
" default initializer for this C++ struct." ,
2399
- " " , PlatformAgnosticAvailabilityKind::Deprecated );
2381
+ " " );
2400
2382
defaultCtor->getAttrs ().add (attr);
2401
2383
}
2402
2384
}
@@ -2910,16 +2892,11 @@ namespace {
2910
2892
auto availability = Impl.SwiftContext .getSwift58Availability ();
2911
2893
if (!availability.isAlwaysAvailable ()) {
2912
2894
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 );
2895
+ auto AvAttr = AvailableAttr::createPlatformVersioned (
2896
+ Impl.SwiftContext , targetPlatform (Impl.SwiftContext .LangOpts ),
2897
+ /* Message=*/ " " , /* Rename=*/ " " ,
2898
+ availability.getRawMinimumVersion (), /* Deprecated=*/ {},
2899
+ /* Obsoleted=*/ {});
2923
2900
classDecl->getAttrs ().add (AvAttr);
2924
2901
}
2925
2902
}
@@ -4408,7 +4385,7 @@ namespace {
4408
4385
decl, AccessLevel::Public, loc, name, loc, std::nullopt,
4409
4386
genericParamList, dc);
4410
4387
4411
- auto attr = AvailableAttr::createPlatformAgnostic (
4388
+ auto attr = AvailableAttr::createUniversallyUnavailable (
4412
4389
Impl.SwiftContext , " Un-specialized class templates are not currently "
4413
4390
" supported. Please use a specialization of this "
4414
4391
" type." );
@@ -5376,8 +5353,8 @@ namespace {
5376
5353
message = " cannot find Swift declaration for this protocol" ;
5377
5354
else
5378
5355
llvm_unreachable (" unknown bridged decl kind" );
5379
- auto attr = AvailableAttr::createPlatformAgnostic (Impl.SwiftContext ,
5380
- message);
5356
+ auto attr = AvailableAttr::createUniversallyUnavailable (Impl.SwiftContext ,
5357
+ message);
5381
5358
VD->getAttrs ().add (attr);
5382
5359
}
5383
5360
@@ -5430,7 +5407,7 @@ namespace {
5430
5407
addObjCAttribute (result,
5431
5408
Impl.importIdentifier (decl->getIdentifier ()));
5432
5409
result->setImplicit ();
5433
- auto attr = AvailableAttr::createPlatformAgnostic (
5410
+ auto attr = AvailableAttr::createUniversallyUnavailable (
5434
5411
Impl.SwiftContext ,
5435
5412
" This Objective-C protocol has only been forward-declared; "
5436
5413
" import its owning module to use it" );
@@ -5585,7 +5562,8 @@ namespace {
5585
5562
auto result = createFakeClass (name, /* cacheResult */ true ,
5586
5563
/* inheritFromNSObject */ true );
5587
5564
result->setImplicit ();
5588
- auto attr = AvailableAttr::createPlatformAgnostic (Impl.SwiftContext ,
5565
+ auto attr = AvailableAttr::createUniversallyUnavailable (
5566
+ Impl.SwiftContext ,
5589
5567
" This Objective-C class has only been forward-declared; "
5590
5568
" import its owning module to use it" );
5591
5569
result->getAttrs ().add (attr);
@@ -6477,7 +6455,7 @@ SwiftDeclConverter::importOptionConstant(const clang::EnumConstantDecl *decl,
6477
6455
!CD->isUnavailable ()) {
6478
6456
// / Create an AvailableAttr that indicates specific availability
6479
6457
// / for all platforms.
6480
- auto attr = AvailableAttr::createPlatformAgnostic (
6458
+ auto attr = AvailableAttr::createUniversallyUnavailable (
6481
6459
Impl.SwiftContext , " use [] to construct an empty option set" );
6482
6460
CD->getAttrs ().add (attr);
6483
6461
}
@@ -7114,7 +7092,7 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
7114
7092
errorStr += objcMethod->getSelector ().getAsString ();
7115
7093
errorStr += ' ]' ;
7116
7094
7117
- auto attr = AvailableAttr::createPlatformAgnostic (
7095
+ auto attr = AvailableAttr::createUniversallyUnavailable (
7118
7096
Impl.SwiftContext , Impl.SwiftContext .AllocateCopy (errorStr.str ()));
7119
7097
ctor->getAttrs ().add (attr);
7120
7098
continue ;
@@ -8795,7 +8773,7 @@ void ClangImporter::Implementation::importAttributes(
8795
8773
//
8796
8774
if (auto unavailable = dyn_cast<clang::UnavailableAttr>(*AI)) {
8797
8775
auto Message = unavailable->getMessage ();
8798
- auto attr = AvailableAttr::createPlatformAgnostic (C, Message);
8776
+ auto attr = AvailableAttr::createUniversallyUnavailable (C, Message);
8799
8777
MappedDecl->getAttrs ().add (attr);
8800
8778
AnyUnavailable = true ;
8801
8779
continue ;
@@ -8808,8 +8786,7 @@ void ClangImporter::Implementation::importAttributes(
8808
8786
//
8809
8787
if (auto unavailable_annot = dyn_cast<clang::AnnotateAttr>(*AI))
8810
8788
if (unavailable_annot->getAnnotation () == " swift1_unavailable" ) {
8811
- auto attr = AvailableAttr::createPlatformAgnostic (
8812
- C, " " , " " , PlatformAgnosticAvailabilityKind::UnavailableInSwift);
8789
+ auto attr = AvailableAttr::createUnavailableInSwift (C, " " , " " );
8813
8790
MappedDecl->getAttrs ().add (attr);
8814
8791
AnyUnavailable = true ;
8815
8792
continue ;
@@ -8822,8 +8799,7 @@ void ClangImporter::Implementation::importAttributes(
8822
8799
//
8823
8800
if (auto deprecated = dyn_cast<clang::DeprecatedAttr>(*AI)) {
8824
8801
auto Message = deprecated->getMessage ();
8825
- auto attr = AvailableAttr::createPlatformAgnostic (C, Message, " " ,
8826
- PlatformAgnosticAvailabilityKind::Deprecated);
8802
+ auto attr = AvailableAttr::createUniversallyDeprecated (C, Message, " " );
8827
8803
MappedDecl->getAttrs ().add (attr);
8828
8804
continue ;
8829
8805
}
@@ -8845,9 +8821,8 @@ void ClangImporter::Implementation::importAttributes(
8845
8821
if (!replacement.empty ())
8846
8822
swiftReplacement = getSwiftNameFromClangName (replacement);
8847
8823
8848
- auto attr = AvailableAttr::createPlatformAgnostic (
8849
- C, avail->getMessage (), swiftReplacement,
8850
- PlatformAgnosticAvailabilityKind::UnavailableInSwift);
8824
+ auto attr = AvailableAttr::createUnavailableInSwift (
8825
+ C, avail->getMessage (), swiftReplacement);
8851
8826
MappedDecl->getAttrs ().add (attr);
8852
8827
AnyUnavailable = true ;
8853
8828
continue ;
@@ -8955,7 +8930,7 @@ void ClangImporter::Implementation::importAttributes(
8955
8930
if (auto ID = dyn_cast<clang::ObjCInterfaceDecl>(ClangDecl)) {
8956
8931
// Ban NSInvocation.
8957
8932
if (ID->getName () == " NSInvocation" ) {
8958
- auto attr = AvailableAttr::createPlatformAgnostic (C, " " );
8933
+ auto attr = AvailableAttr::createUniversallyUnavailable (C, " " );
8959
8934
MappedDecl->getAttrs ().add (attr);
8960
8935
return ;
8961
8936
}
@@ -8988,8 +8963,8 @@ void ClangImporter::Implementation::importAttributes(
8988
8963
!FD->getAttr <clang::SwiftNameAttr>()) {
8989
8964
if (auto t = FD->getParamDecl (0 )->getType ()->getAs <clang::TypedefType>()){
8990
8965
if (isCFTypeDecl (t->getDecl ())) {
8991
- auto attr = AvailableAttr::createPlatformAgnostic (C,
8992
- " Core Foundation objects are automatically memory managed" );
8966
+ auto attr = AvailableAttr::createUniversallyUnavailable (
8967
+ C, " Core Foundation objects are automatically memory managed" );
8993
8968
MappedDecl->getAttrs ().add (attr);
8994
8969
return ;
8995
8970
}
@@ -9677,8 +9652,8 @@ void ClangImporter::Implementation::
9677
9652
markUnavailable (ValueDecl *decl, StringRef unavailabilityMsgRef) {
9678
9653
9679
9654
unavailabilityMsgRef = SwiftContext.AllocateCopy (unavailabilityMsgRef);
9680
- auto ua = AvailableAttr::createPlatformAgnostic (SwiftContext,
9681
- unavailabilityMsgRef);
9655
+ auto ua = AvailableAttr::createUniversallyUnavailable (SwiftContext,
9656
+ unavailabilityMsgRef);
9682
9657
decl->getAttrs ().add (ua);
9683
9658
}
9684
9659
0 commit comments