@@ -536,20 +536,17 @@ static void applyAvailableAttribute(Decl *decl, AvailabilityRange &info,
536536 return ;
537537
538538 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 );
553550
554551 decl->getAttrs ().add (AvAttr);
555552}
@@ -1316,14 +1313,13 @@ namespace {
13161313 : llvm::VersionTuple (majorVersion);
13171314 attr = new (ctx) AvailableAttr (
13181315 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 (),
13241320 PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
1325- /* Implicit*/ false ,
1326- /* SPI*/ false );
1321+ /* Implicit= */ false ,
1322+ /* SPI= */ false );
13271323 }
13281324 }
13291325
@@ -2880,15 +2876,16 @@ namespace {
28802876 auto availability = Impl.SwiftContext .getSwift58Availability ();
28812877 if (!availability.isAlwaysAvailable ()) {
28822878 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 );
28922889 classDecl->getAttrs ().add (AvAttr);
28932890 }
28942891 }
@@ -7883,12 +7880,28 @@ void addCompletionHandlerAttribute(Decl *asyncImport,
78837880 return ;
78847881
78857882 for (auto *member : members) {
7883+ if (member == asyncImport)
7884+ continue ;
7885+
7886+ auto afd = dyn_cast<AbstractFunctionDecl>(member);
7887+ if (!afd)
7888+ continue ;
7889+
78867890 // 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);
78927905 }
78937906}
78947907
@@ -8696,18 +8709,11 @@ void ClangImporter::Implementation::importAttributes(
86968709 if (!replacement.empty ())
86978710 swiftReplacement = getSwiftNameFromClangName (replacement);
86988711
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);
87118717
87128718 MappedDecl->getAttrs ().add (AvAttr);
87138719 }
0 commit comments