@@ -2106,20 +2106,18 @@ Type RawLayoutAttr::getResolvedCountType(StructDecl *sd) const {
21062106#define INIT_VER_TUPLE (X ) X(X.empty() ? std::optional<llvm::VersionTuple>() : X)
21072107
21082108AvailableAttr::AvailableAttr (
2109- SourceLoc AtLoc, SourceRange Range, PlatformKind Platform ,
2110- StringRef Message, StringRef Rename,
2109+ SourceLoc AtLoc, SourceRange Range, const AvailabilityDomain &Domain ,
2110+ Kind Kind, StringRef Message, StringRef Rename,
21112111 const llvm::VersionTuple &Introduced, SourceRange IntroducedRange,
21122112 const llvm::VersionTuple &Deprecated, SourceRange DeprecatedRange,
21132113 const llvm::VersionTuple &Obsoleted, SourceRange ObsoletedRange,
2114- PlatformAgnosticAvailabilityKind PlatformAgnostic, bool Implicit,
2115- bool IsSPI, bool IsForEmbedded)
2114+ bool Implicit, bool IsSPI, bool IsForEmbedded)
21162115 : DeclAttribute(DeclAttrKind::Available, AtLoc, Range, Implicit),
2117- Message(Message), Rename(Rename),
2116+ Domain(Domain), Message(Message), Rename(Rename),
21182117 INIT_VER_TUPLE(Introduced), IntroducedRange(IntroducedRange),
21192118 INIT_VER_TUPLE(Deprecated), DeprecatedRange(DeprecatedRange),
21202119 INIT_VER_TUPLE(Obsoleted), ObsoletedRange(ObsoletedRange) {
2121- Bits.AvailableAttr .Platform = static_cast <uint8_t >(Platform);
2122- Bits.AvailableAttr .PlatformAgnostic = static_cast <uint8_t >(PlatformAgnostic);
2120+ Bits.AvailableAttr .Kind = static_cast <uint8_t >(Kind);
21232121 Bits.AvailableAttr .HasComputedRenamedDecl = false ;
21242122 Bits.AvailableAttr .HasRenamedDecl = false ;
21252123 Bits.AvailableAttr .IsSPI = IsSPI;
@@ -2128,52 +2126,10 @@ AvailableAttr::AvailableAttr(
21282126 // FIXME: [availability] The IsForEmbedded bit should be removed when
21292127 // it can be represented with AvailabilityDomain (rdar://138802876)
21302128 Bits.AvailableAttr .IsForEmbedded = true ;
2131- assert (getPlatform () == PlatformKind::none);
2132- }
2133- }
2134-
2135- static PlatformAgnosticAvailabilityKind
2136- platformAgnosticFromDomainAndKind (const AvailabilityDomain &Domain,
2137- AvailableAttr::Kind Kind) {
2138- switch (Kind) {
2139- case swift::AvailableAttr::Kind::NoAsync:
2140- return PlatformAgnosticAvailabilityKind::NoAsync;
2141-
2142- case swift::AvailableAttr::Kind::Default:
2143- if (Domain.isSwiftLanguage ()) {
2144- return PlatformAgnosticAvailabilityKind::SwiftVersionSpecific;
2145- } else if (Domain.isPackageDescription ()) {
2146- return PlatformAgnosticAvailabilityKind::
2147- PackageDescriptionVersionSpecific;
2148- }
2149- return PlatformAgnosticAvailabilityKind::None;
2150-
2151- case swift::AvailableAttr::Kind::Deprecated:
2152- return PlatformAgnosticAvailabilityKind::Deprecated;
2153-
2154- case swift::AvailableAttr::Kind::Unavailable:
2155- if (Domain.isSwiftLanguage ()) {
2156- return PlatformAgnosticAvailabilityKind::UnavailableInSwift;
2157- } else if (Domain.isUniversal () || Domain.isPlatform ()) {
2158- return PlatformAgnosticAvailabilityKind::Unavailable;
2159- }
2160- llvm_unreachable (" unexpected domain for unavailable attr" );
2129+ assert (Domain.isUniversal ());
21612130 }
21622131}
21632132
2164- AvailableAttr::AvailableAttr (
2165- SourceLoc AtLoc, SourceRange Range, const AvailabilityDomain &Domain,
2166- Kind Kind, StringRef Message, StringRef Rename,
2167- const llvm::VersionTuple &Introduced, SourceRange IntroducedRange,
2168- const llvm::VersionTuple &Deprecated, SourceRange DeprecatedRange,
2169- const llvm::VersionTuple &Obsoleted, SourceRange ObsoletedRange,
2170- bool Implicit, bool IsSPI, bool IsForEmbedded)
2171- : AvailableAttr(AtLoc, Range, Domain.getPlatformKind(), Message, Rename,
2172- Introduced, IntroducedRange, Deprecated, DeprecatedRange,
2173- Obsoleted, ObsoletedRange,
2174- platformAgnosticFromDomainAndKind(Domain, Kind), Implicit,
2175- IsSPI, IsForEmbedded) {}
2176-
21772133#undef INIT_VER_TUPLE
21782134
21792135AvailableAttr *AvailableAttr::createUniversallyUnavailable (ASTContext &C,
@@ -2241,16 +2197,16 @@ bool BackDeployedAttr::isActivePlatform(const ASTContext &ctx,
22412197}
22422198
22432199AvailableAttr *AvailableAttr::clone (ASTContext &C, bool implicit) const {
2244- return new (C) AvailableAttr (
2245- implicit ? SourceLoc () : AtLoc, implicit ? SourceRange () : getRange (),
2246- getPlatform (), Message, Rename,
2247- Introduced ? *Introduced : llvm::VersionTuple (),
2248- implicit ? SourceRange () : IntroducedRange,
2249- Deprecated ? *Deprecated : llvm::VersionTuple (),
2250- implicit ? SourceRange () : DeprecatedRange,
2251- Obsoleted ? *Obsoleted : llvm::VersionTuple (),
2252- implicit ? SourceRange () : ObsoletedRange,
2253- getPlatformAgnosticAvailability (), implicit, isSPI (), isForEmbedded ());
2200+ return new (C) AvailableAttr (implicit ? SourceLoc () : AtLoc,
2201+ implicit ? SourceRange () : getRange (), Domain ,
2202+ getKind (), Message, Rename,
2203+ Introduced ? *Introduced : llvm::VersionTuple (),
2204+ implicit ? SourceRange () : IntroducedRange,
2205+ Deprecated ? *Deprecated : llvm::VersionTuple (),
2206+ implicit ? SourceRange () : DeprecatedRange,
2207+ Obsoleted ? *Obsoleted : llvm::VersionTuple (),
2208+ implicit ? SourceRange () : ObsoletedRange,
2209+ implicit, isSPI (), isForEmbedded ());
22542210}
22552211
22562212std::optional<OriginallyDefinedInAttr::ActiveVersion>
0 commit comments