@@ -421,8 +421,9 @@ DeclAttributes::getBackDeployed(const ASTContext &ctx,
421421
422422 // We have an attribute that is active for the platform, but
423423 // is it more specific than our current best?
424- if (!bestAttr || inheritsAvailabilityFromPlatform (
425- backDeployedAttr->Platform , bestAttr->Platform )) {
424+ if (!bestAttr ||
425+ inheritsAvailabilityFromPlatform (backDeployedAttr->getPlatform (),
426+ bestAttr->getPlatform ())) {
426427 bestAttr = backDeployedAttr;
427428 }
428429 }
@@ -557,8 +558,8 @@ static void printShortFormBackDeployed(ArrayRef<const DeclAttribute *> Attrs,
557558 if (!isFirst)
558559 Printer << " , " ;
559560 auto *attr = cast<BackDeployedAttr>(DA);
560- Printer << platformString (attr->Platform ) << " "
561- << attr->Version .getAsString ();
561+ Printer << platformString (attr->getPlatform () ) << " "
562+ << attr->getVersion () .getAsString ();
562563 isFirst = false ;
563564 }
564565 Printer << " )" ;
@@ -771,9 +772,9 @@ static std::optional<PlatformKind> referencedPlatform(const DeclAttribute *attr,
771772 }
772773 return std::nullopt ;
773774 case DeclAttrKind::BackDeployed:
774- return static_cast <const BackDeployedAttr *>(attr)->Platform ;
775+ return static_cast <const BackDeployedAttr *>(attr)->getPlatform () ;
775776 case DeclAttrKind::OriginallyDefinedIn:
776- return static_cast <const OriginallyDefinedInAttr *>(attr)->Platform ;
777+ return static_cast <const OriginallyDefinedInAttr *>(attr)->getPlatform () ;
777778 default :
778779 return std::nullopt ;
779780 }
@@ -1094,7 +1095,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
10941095 case DeclAttrKind::OriginallyDefinedIn: {
10951096 auto Attr = cast<OriginallyDefinedInAttr>(this );
10961097 auto Name = D->getDeclContext ()->getParentModule ()->getName ().str ();
1097- if (Options.IsForSwiftInterface && Attr->ManglingModuleName == Name)
1098+ if (Options.IsForSwiftInterface && Attr->getManglingModuleName () == Name)
10981099 return false ;
10991100 break ;
11001101 }
@@ -1195,13 +1196,15 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
11951196 Printer.printAttrName (" @_originallyDefinedIn" );
11961197 Printer << " (module: " ;
11971198 auto Attr = cast<OriginallyDefinedInAttr>(this );
1198- Printer << " \" " << Attr->ManglingModuleName ;
1199- ASSERT (!Attr->ManglingModuleName .empty ());
1200- ASSERT (!Attr->LinkerModuleName .empty ());
1201- if (Attr->LinkerModuleName != Attr->ManglingModuleName )
1202- Printer << " ;" << Attr->LinkerModuleName ;
1203- Printer << " \" , " << platformString (Attr->Platform ) << " " <<
1204- Attr->MovedVersion .getAsString ();
1199+ auto ManglingModuleName = Attr->getManglingModuleName ();
1200+ auto LinkerModuleName = Attr->getLinkerModuleName ();
1201+ Printer << " \" " << ManglingModuleName;
1202+ ASSERT (!ManglingModuleName.empty ());
1203+ ASSERT (!LinkerModuleName.empty ());
1204+ if (LinkerModuleName != ManglingModuleName)
1205+ Printer << " ;" << LinkerModuleName;
1206+ Printer << " \" , " << platformString (Attr->getPlatform ()) << " "
1207+ << Attr->getMovedVersion ().getAsString ();
12051208 Printer << " )" ;
12061209 break ;
12071210 }
@@ -1517,8 +1520,8 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
15171520 Printer.printAttrName (" @backDeployed" );
15181521 Printer << " (before: " ;
15191522 auto Attr = cast<BackDeployedAttr>(this );
1520- Printer << platformString (Attr->Platform ) << " " <<
1521- Attr->Version .getAsString ();
1523+ Printer << platformString (Attr->getPlatform ()) << " "
1524+ << Attr->getVersion () .getAsString ();
15221525 Printer << " )" ;
15231526 break ;
15241527 }
@@ -2348,6 +2351,10 @@ AvailableAttr *AvailableAttr::createUnavailableInEmbedded(ASTContext &C,
23482351 /* Implicit=*/ false , /* IsSPI=*/ false );
23492352}
23502353
2354+ llvm::VersionTuple BackDeployedAttr::getVersion () const {
2355+ return canonicalizePlatformVersion (getPlatform (), getParsedVersion ());
2356+ }
2357+
23512358bool BackDeployedAttr::isActivePlatform (const ASTContext &ctx,
23522359 bool forTargetVariant) const {
23532360 return isPlatformActive (Platform, ctx.LangOpts , forTargetVariant);
@@ -2375,14 +2382,14 @@ bool AvailableAttr::isEquivalent(const AvailableAttr *other,
23752382 == attachedTo->getSemanticAvailableAttr (other)->getDomain ();
23762383}
23772384
2378- static StringRef getManglingModuleName (StringRef OriginalModuleName) {
2385+ static StringRef parseManglingModuleName (StringRef OriginalModuleName) {
23792386 auto index = OriginalModuleName.find (" ;" );
23802387 return index == StringRef::npos
23812388 ? OriginalModuleName
23822389 : OriginalModuleName.slice (0 , index);
23832390}
23842391
2385- static StringRef getLinkerModuleName (StringRef OriginalModuleName) {
2392+ static StringRef parseLinkerModuleName (StringRef OriginalModuleName) {
23862393 auto index = OriginalModuleName.find (" ;" );
23872394 return index == StringRef::npos
23882395 ? OriginalModuleName
@@ -2393,16 +2400,19 @@ OriginallyDefinedInAttr::OriginallyDefinedInAttr(
23932400 SourceLoc AtLoc, SourceRange Range, StringRef OriginalModuleName,
23942401 PlatformKind Platform, const llvm::VersionTuple MovedVersion, bool Implicit)
23952402 : DeclAttribute(DeclAttrKind::OriginallyDefinedIn, AtLoc, Range, Implicit),
2396- ManglingModuleName(getManglingModuleName(OriginalModuleName)),
2397- LinkerModuleName(getLinkerModuleName(OriginalModuleName)),
2398- Platform(Platform),
2399- MovedVersion(canonicalizePlatformVersion(Platform, MovedVersion)) {}
2403+ ManglingModuleName(parseManglingModuleName(OriginalModuleName)),
2404+ LinkerModuleName(parseLinkerModuleName(OriginalModuleName)),
2405+ Platform(Platform), MovedVersion(MovedVersion) {}
2406+
2407+ llvm::VersionTuple OriginallyDefinedInAttr::getMovedVersion () const {
2408+ return canonicalizePlatformVersion (getPlatform (), getParsedMovedVersion ());
2409+ }
24002410
24012411std::optional<OriginallyDefinedInAttr::ActiveVersion>
24022412OriginallyDefinedInAttr::isActivePlatform (const ASTContext &ctx) const {
24032413 OriginallyDefinedInAttr::ActiveVersion Result;
24042414 Result.Platform = Platform;
2405- Result.Version = MovedVersion ;
2415+ Result.Version = getMovedVersion () ;
24062416 Result.ManglingModuleName = ManglingModuleName;
24072417 Result.LinkerModuleName = LinkerModuleName;
24082418 if (isPlatformActive (Platform, ctx.LangOpts , /* TargetVariant*/ false )) {
0 commit comments