@@ -662,7 +662,7 @@ static bool isShortAvailable(const DeclAttribute *DA) {
662662 if (!AvailAttr)
663663 return false ;
664664
665- if (AvailAttr->IsSPI )
665+ if (AvailAttr->isSPI () )
666666 return false ;
667667
668668 if (!AvailAttr->Introduced .has_value ())
@@ -1371,7 +1371,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
13711371 auto Attr = cast<AvailableAttr>(this );
13721372 if (Options.SuppressNoAsyncAvailabilityAttr && Attr->isNoAsync ())
13731373 return false ;
1374- if (Options.printPublicInterface () && Attr->IsSPI ) {
1374+ if (Options.printPublicInterface () && Attr->isSPI () ) {
13751375 assert (Attr->hasPlatform ());
13761376 assert (Attr->Introduced .has_value ());
13771377 Printer.printAttrName (" @available" );
@@ -1380,7 +1380,14 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
13801380 Printer << " , unavailable)" ;
13811381 break ;
13821382 }
1383- if (Attr->IsSPI ) {
1383+ if (Attr->isForEmbedded ()) {
1384+ std::string atUnavailableInEmbedded =
1385+ (llvm::Twine (" @" ) + UNAVAILABLE_IN_EMBEDDED_ATTRNAME).str ();
1386+ Printer.printAttrName (atUnavailableInEmbedded);
1387+ break ;
1388+ }
1389+
1390+ if (Attr->isSPI ()) {
13841391 std::string atSPI = (llvm::Twine (" @" ) + SPI_AVAILABLE_ATTRNAME).str ();
13851392 Printer.printAttrName (atSPI);
13861393 } else {
@@ -2243,6 +2250,34 @@ Type RawLayoutAttr::getResolvedCountType(StructDecl *sd) const {
22432250 ErrorType::get (ctx));
22442251}
22452252
2253+ #define INIT_VER_TUPLE (X ) X(X.empty() ? std::optional<llvm::VersionTuple>() : X)
2254+
2255+ AvailableAttr::AvailableAttr (
2256+ SourceLoc AtLoc, SourceRange Range, PlatformKind Platform,
2257+ StringRef Message, StringRef Rename, ValueDecl *RenameDecl,
2258+ const llvm::VersionTuple &Introduced, SourceRange IntroducedRange,
2259+ const llvm::VersionTuple &Deprecated, SourceRange DeprecatedRange,
2260+ const llvm::VersionTuple &Obsoleted, SourceRange ObsoletedRange,
2261+ PlatformAgnosticAvailabilityKind PlatformAgnostic, bool Implicit,
2262+ bool IsSPI, bool IsForEmbedded)
2263+ : DeclAttribute(DeclAttrKind::Available, AtLoc, Range, Implicit),
2264+ Message(Message), Rename(Rename), RenameDecl(RenameDecl),
2265+ INIT_VER_TUPLE(Introduced), IntroducedRange(IntroducedRange),
2266+ INIT_VER_TUPLE(Deprecated), DeprecatedRange(DeprecatedRange),
2267+ INIT_VER_TUPLE(Obsoleted), ObsoletedRange(ObsoletedRange),
2268+ PlatformAgnostic(PlatformAgnostic), Platform(Platform) {
2269+ Bits.AvailableAttr .IsSPI = IsSPI;
2270+
2271+ if (IsForEmbedded) {
2272+ // FIXME: The IsForEmbedded bit should be removed when library availability
2273+ // conditions are implemented (rdar://138802876)
2274+ Bits.AvailableAttr .IsForEmbedded = true ;
2275+ assert (Platform == PlatformKind::none);
2276+ }
2277+ }
2278+
2279+ #undef INIT_VER_TUPLE
2280+
22462281AvailableAttr *
22472282AvailableAttr::createPlatformAgnostic (ASTContext &C,
22482283 StringRef Message,
@@ -2294,7 +2329,8 @@ AvailableAttr *AvailableAttr::clone(ASTContext &C, bool implicit) const {
22942329 implicit ? SourceRange () : ObsoletedRange,
22952330 PlatformAgnostic,
22962331 implicit,
2297- IsSPI);
2332+ isSPI (),
2333+ isForEmbedded ());
22982334}
22992335
23002336std::optional<OriginallyDefinedInAttr::ActiveVersion>
0 commit comments