@@ -536,20 +536,17 @@ static void applyAvailableAttribute(Decl *decl, AvailabilityRange &info,
536
536
return ;
537
537
538
538
llvm::VersionTuple noVersion;
539
- auto AvAttr = new (C) AvailableAttr (SourceLoc (), SourceRange (),
540
- targetPlatform (C.LangOpts ),
541
- /* Message=*/ StringRef (),
542
- /* Rename=*/ StringRef (),
543
- /* RenameDecl=*/ nullptr ,
544
- info.getRawMinimumVersion (),
545
- /* IntroducedRange*/ SourceRange (),
546
- /* Deprecated=*/ noVersion,
547
- /* DeprecatedRange*/ SourceRange (),
548
- /* Obsoleted=*/ noVersion,
549
- /* ObsoletedRange*/ SourceRange (),
550
- PlatformAgnosticAvailabilityKind::None,
551
- /* Implicit=*/ false ,
552
- /* SPI*/ false );
539
+ auto AvAttr = new (C) AvailableAttr (
540
+ SourceLoc (), SourceRange (), targetPlatform (C.LangOpts ),
541
+ /* Message=*/ StringRef (),
542
+ /* Rename=*/ StringRef (), info.getRawMinimumVersion (),
543
+ /* IntroducedRange=*/ SourceRange (),
544
+ /* Deprecated=*/ noVersion,
545
+ /* DeprecatedRange=*/ SourceRange (),
546
+ /* Obsoleted=*/ noVersion,
547
+ /* ObsoletedRange=*/ SourceRange (), PlatformAgnosticAvailabilityKind::None,
548
+ /* Implicit=*/ false ,
549
+ /* SPI=*/ false );
553
550
554
551
decl->getAttrs ().add (AvAttr);
555
552
}
@@ -1316,14 +1313,13 @@ namespace {
1316
1313
: llvm::VersionTuple (majorVersion);
1317
1314
attr = new (ctx) AvailableAttr (
1318
1315
SourceLoc (), SourceRange (), PlatformKind::none,
1319
- /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1320
- /* RenameDecl=*/ nullptr ,
1321
- /* Introduced*/ introducedVersion, SourceRange (),
1322
- /* Deprecated*/ llvm::VersionTuple (), SourceRange (),
1323
- /* Obsoleted*/ llvm::VersionTuple (), SourceRange (),
1316
+ /* Message=*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
1317
+ /* Introduced=*/ introducedVersion, SourceRange (),
1318
+ /* Deprecated=*/ llvm::VersionTuple (), SourceRange (),
1319
+ /* Obsoleted=*/ llvm::VersionTuple (), SourceRange (),
1324
1320
PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
1325
- /* Implicit*/ false ,
1326
- /* SPI*/ false );
1321
+ /* Implicit= */ false ,
1322
+ /* SPI= */ false );
1327
1323
}
1328
1324
}
1329
1325
@@ -2880,15 +2876,16 @@ namespace {
2880
2876
auto availability = Impl.SwiftContext .getSwift58Availability ();
2881
2877
if (!availability.isAlwaysAvailable ()) {
2882
2878
assert (availability.hasMinimumVersion ());
2883
- auto AvAttr = new (Impl.SwiftContext ) AvailableAttr (
2884
- SourceLoc (), SourceRange (),
2885
- targetPlatform (Impl.SwiftContext .LangOpts ), " " , " " ,
2886
- /* RenameDecl=*/ nullptr , availability.getRawMinimumVersion (),
2887
- /* IntroducedRange=*/ SourceRange (), {},
2888
- /* DeprecatedRange=*/ SourceRange (), {},
2889
- /* ObsoletedRange=*/ SourceRange (),
2890
- PlatformAgnosticAvailabilityKind::None, /* Implicit=*/ false ,
2891
- false );
2879
+ auto AvAttr = new (Impl.SwiftContext )
2880
+ AvailableAttr (SourceLoc (), SourceRange (),
2881
+ targetPlatform (Impl.SwiftContext .LangOpts ),
2882
+ /* Message=*/ " " , /* Rename=*/ " " ,
2883
+ availability.getRawMinimumVersion (),
2884
+ /* IntroducedRange=*/ SourceRange (), {},
2885
+ /* DeprecatedRange=*/ SourceRange (), {},
2886
+ /* ObsoletedRange=*/ SourceRange (),
2887
+ PlatformAgnosticAvailabilityKind::None,
2888
+ /* Implicit=*/ false , false );
2892
2889
classDecl->getAttrs ().add (AvAttr);
2893
2890
}
2894
2891
}
@@ -7883,12 +7880,28 @@ void addCompletionHandlerAttribute(Decl *asyncImport,
7883
7880
return ;
7884
7881
7885
7882
for (auto *member : members) {
7883
+ if (member == asyncImport)
7884
+ continue ;
7885
+
7886
+ auto afd = dyn_cast<AbstractFunctionDecl>(member);
7887
+ if (!afd)
7888
+ continue ;
7889
+
7886
7890
// Only add the attribute to functions that don't already have availability
7887
- if (member != asyncImport && isa<AbstractFunctionDecl>(member) &&
7888
- !member->getAttrs ().hasAttribute <AvailableAttr>()) {
7889
- member->getAttrs ().add (
7890
- AvailableAttr::createForAsyncAlternative (SwiftContext, asyncFunc));
7891
- }
7891
+ if (afd->getAttrs ().hasAttribute <AvailableAttr>())
7892
+ continue ;
7893
+
7894
+ llvm::VersionTuple NoVersion;
7895
+ auto *attr = new (SwiftContext)
7896
+ AvailableAttr (SourceLoc (), SourceRange (), PlatformKind::none,
7897
+ /* Message=*/ " " , /* Rename=*/ " " , /* Introduced=*/ NoVersion,
7898
+ SourceRange (), /* Deprecated=*/ NoVersion, SourceRange (),
7899
+ /* Obsoleted=*/ NoVersion, SourceRange (),
7900
+ PlatformAgnosticAvailabilityKind::None, /* Implicit=*/ true ,
7901
+ /* SPI=*/ false );
7902
+
7903
+ afd->setRenamedDecl (attr, asyncFunc);
7904
+ afd->getAttrs ().add (attr);
7892
7905
}
7893
7906
}
7894
7907
@@ -8696,18 +8709,11 @@ void ClangImporter::Implementation::importAttributes(
8696
8709
if (!replacement.empty ())
8697
8710
swiftReplacement = getSwiftNameFromClangName (replacement);
8698
8711
8699
- auto AvAttr = new (C) AvailableAttr (SourceLoc (), SourceRange (),
8700
- platformK.value (),
8701
- message, swiftReplacement,
8702
- /* RenameDecl=*/ nullptr ,
8703
- introduced,
8704
- /* IntroducedRange=*/ SourceRange (),
8705
- deprecated,
8706
- /* DeprecatedRange=*/ SourceRange (),
8707
- obsoleted,
8708
- /* ObsoletedRange=*/ SourceRange (),
8709
- PlatformAgnostic, /* Implicit=*/ false ,
8710
- EnableClangSPI && IsSPI);
8712
+ auto AvAttr = new (C) AvailableAttr (
8713
+ SourceLoc (), SourceRange (), platformK.value (), message,
8714
+ swiftReplacement, introduced, SourceRange (), deprecated,
8715
+ SourceRange (), obsoleted, SourceRange (), PlatformAgnostic,
8716
+ /* Implicit=*/ false , EnableClangSPI && IsSPI);
8711
8717
8712
8718
MappedDecl->getAttrs ().add (AvAttr);
8713
8719
}
0 commit comments