@@ -421,8 +421,9 @@ DeclAttributes::getBackDeployed(const ASTContext &ctx,
421
421
422
422
// We have an attribute that is active for the platform, but
423
423
// 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 ())) {
426
427
bestAttr = backDeployedAttr;
427
428
}
428
429
}
@@ -557,8 +558,8 @@ static void printShortFormBackDeployed(ArrayRef<const DeclAttribute *> Attrs,
557
558
if (!isFirst)
558
559
Printer << " , " ;
559
560
auto *attr = cast<BackDeployedAttr>(DA);
560
- Printer << platformString (attr->Platform ) << " "
561
- << attr->Version .getAsString ();
561
+ Printer << platformString (attr->getPlatform () ) << " "
562
+ << attr->getVersion () .getAsString ();
562
563
isFirst = false ;
563
564
}
564
565
Printer << " )" ;
@@ -771,9 +772,9 @@ static std::optional<PlatformKind> referencedPlatform(const DeclAttribute *attr,
771
772
}
772
773
return std::nullopt ;
773
774
case DeclAttrKind::BackDeployed:
774
- return static_cast <const BackDeployedAttr *>(attr)->Platform ;
775
+ return static_cast <const BackDeployedAttr *>(attr)->getPlatform () ;
775
776
case DeclAttrKind::OriginallyDefinedIn:
776
- return static_cast <const OriginallyDefinedInAttr *>(attr)->Platform ;
777
+ return static_cast <const OriginallyDefinedInAttr *>(attr)->getPlatform () ;
777
778
default :
778
779
return std::nullopt ;
779
780
}
@@ -1094,7 +1095,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
1094
1095
case DeclAttrKind::OriginallyDefinedIn: {
1095
1096
auto Attr = cast<OriginallyDefinedInAttr>(this );
1096
1097
auto Name = D->getDeclContext ()->getParentModule ()->getName ().str ();
1097
- if (Options.IsForSwiftInterface && Attr->ManglingModuleName == Name)
1098
+ if (Options.IsForSwiftInterface && Attr->getManglingModuleName () == Name)
1098
1099
return false ;
1099
1100
break ;
1100
1101
}
@@ -1195,13 +1196,15 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
1195
1196
Printer.printAttrName (" @_originallyDefinedIn" );
1196
1197
Printer << " (module: " ;
1197
1198
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 ();
1205
1208
Printer << " )" ;
1206
1209
break ;
1207
1210
}
@@ -1517,8 +1520,8 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
1517
1520
Printer.printAttrName (" @backDeployed" );
1518
1521
Printer << " (before: " ;
1519
1522
auto Attr = cast<BackDeployedAttr>(this );
1520
- Printer << platformString (Attr->Platform ) << " " <<
1521
- Attr->Version .getAsString ();
1523
+ Printer << platformString (Attr->getPlatform ()) << " "
1524
+ << Attr->getVersion () .getAsString ();
1522
1525
Printer << " )" ;
1523
1526
break ;
1524
1527
}
@@ -2348,6 +2351,10 @@ AvailableAttr *AvailableAttr::createUnavailableInEmbedded(ASTContext &C,
2348
2351
/* Implicit=*/ false , /* IsSPI=*/ false );
2349
2352
}
2350
2353
2354
+ llvm::VersionTuple BackDeployedAttr::getVersion () const {
2355
+ return canonicalizePlatformVersion (getPlatform (), getParsedVersion ());
2356
+ }
2357
+
2351
2358
bool BackDeployedAttr::isActivePlatform (const ASTContext &ctx,
2352
2359
bool forTargetVariant) const {
2353
2360
return isPlatformActive (Platform, ctx.LangOpts , forTargetVariant);
@@ -2375,14 +2382,14 @@ bool AvailableAttr::isEquivalent(const AvailableAttr *other,
2375
2382
== attachedTo->getSemanticAvailableAttr (other)->getDomain ();
2376
2383
}
2377
2384
2378
- static StringRef getManglingModuleName (StringRef OriginalModuleName) {
2385
+ static StringRef parseManglingModuleName (StringRef OriginalModuleName) {
2379
2386
auto index = OriginalModuleName.find (" ;" );
2380
2387
return index == StringRef::npos
2381
2388
? OriginalModuleName
2382
2389
: OriginalModuleName.slice (0 , index);
2383
2390
}
2384
2391
2385
- static StringRef getLinkerModuleName (StringRef OriginalModuleName) {
2392
+ static StringRef parseLinkerModuleName (StringRef OriginalModuleName) {
2386
2393
auto index = OriginalModuleName.find (" ;" );
2387
2394
return index == StringRef::npos
2388
2395
? OriginalModuleName
@@ -2393,16 +2400,19 @@ OriginallyDefinedInAttr::OriginallyDefinedInAttr(
2393
2400
SourceLoc AtLoc, SourceRange Range, StringRef OriginalModuleName,
2394
2401
PlatformKind Platform, const llvm::VersionTuple MovedVersion, bool Implicit)
2395
2402
: 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
+ }
2400
2410
2401
2411
std::optional<OriginallyDefinedInAttr::ActiveVersion>
2402
2412
OriginallyDefinedInAttr::isActivePlatform (const ASTContext &ctx) const {
2403
2413
OriginallyDefinedInAttr::ActiveVersion Result;
2404
2414
Result.Platform = Platform;
2405
- Result.Version = MovedVersion ;
2415
+ Result.Version = getMovedVersion () ;
2406
2416
Result.ManglingModuleName = ManglingModuleName;
2407
2417
Result.LinkerModuleName = LinkerModuleName;
2408
2418
if (isPlatformActive (Platform, ctx.LangOpts , /* TargetVariant*/ false )) {
0 commit comments