@@ -798,22 +798,27 @@ bool Parser::parseAvailability(
798798 if (Spec->isWildcard ())
799799 continue ;
800800
801- std::optional<AvailabilityDomain> Domain = Spec->getDomain ();
802- if (!Domain)
801+ auto DomainOrIdentifier = Spec->getDomainOrIdentifier ();
802+
803+ // The domain should not be resolved during parsing.
804+ DEBUG_ASSERT (!DomainOrIdentifier.isDomain ());
805+
806+ auto DomainIdentifier = DomainOrIdentifier.getAsIdentifier ();
807+ if (!DomainIdentifier)
803808 continue ;
804809
805- auto Attr = new (Context)
806- AvailableAttr ( AtLoc, attrRange, *Domain , Spec->getSourceRange ().Start ,
807- AvailableAttr::Kind::Default,
808- /* Message=*/ StringRef (),
809- /* Rename=*/ StringRef (),
810- /* Introduced=*/ Spec->getRawVersion (),
811- /* IntroducedRange=*/ Spec->getVersionSrcRange (),
812- /* Deprecated=*/ llvm::VersionTuple (),
813- /* DeprecatedRange=*/ SourceRange (),
814- /* Obsoleted=*/ llvm::VersionTuple (),
815- /* ObsoletedRange=*/ SourceRange (),
816- /* Implicit=*/ false , AttrName == SPI_AVAILABLE_ATTRNAME);
810+ auto Attr = new (Context) AvailableAttr (
811+ AtLoc, attrRange, *DomainIdentifier , Spec->getSourceRange ().Start ,
812+ AvailableAttr::Kind::Default,
813+ /* Message=*/ StringRef (),
814+ /* Rename=*/ StringRef (),
815+ /* Introduced=*/ Spec->getRawVersion (),
816+ /* IntroducedRange=*/ Spec->getVersionSrcRange (),
817+ /* Deprecated=*/ llvm::VersionTuple (),
818+ /* DeprecatedRange=*/ SourceRange (),
819+ /* Obsoleted=*/ llvm::VersionTuple (),
820+ /* ObsoletedRange=*/ SourceRange (),
821+ /* Implicit=*/ false , AttrName == SPI_AVAILABLE_ATTRNAME);
817822 addAttribute (Attr);
818823
819824 Attr->setIsGroupMember ();
@@ -1875,6 +1880,18 @@ Parser::parseAvailabilityMacro(SmallVectorImpl<AvailabilitySpec *> &Specs) {
18751880 return makeParserSuccess ();
18761881}
18771882
1883+ static PlatformKind getPlatformFromDomainOrIdentifier (
1884+ const AvailabilityDomainOrIdentifier &domainOrIdentifier) {
1885+ if (auto domain = domainOrIdentifier.getAsDomain ())
1886+ return domain->getPlatformKind ();
1887+
1888+ if (auto platform =
1889+ platformFromString (domainOrIdentifier.getAsIdentifier ()->str ()))
1890+ return *platform;
1891+
1892+ return PlatformKind::none;
1893+ }
1894+
18781895ParserStatus Parser::parsePlatformVersionInList (StringRef AttrName,
18791896 llvm::SmallVector<PlatformAndVersion, 4 > &PlatformAndVersions,
18801897 bool &ParsedUnrecognizedPlatformName) {
@@ -1886,10 +1903,10 @@ ParserStatus Parser::parsePlatformVersionInList(StringRef AttrName,
18861903 return MacroStatus;
18871904
18881905 for (auto *Spec : Specs) {
1889- auto Platform = Spec-> getPlatform ();
1890- // Since peekAvailabilityMacroName() only matches defined availability
1891- // macros, we only expect platform specific constraints here.
1892- DEBUG_ASSERT (Platform != PlatformKind::none) ;
1906+ auto Platform =
1907+ getPlatformFromDomainOrIdentifier (Spec-> getDomainOrIdentifier ());
1908+ if (Platform == PlatformKind::none)
1909+ continue ;
18931910
18941911 auto Version = Spec->getRawVersion ();
18951912 if (Version.getSubminor ().has_value () || Version.getBuild ().has_value ()) {
0 commit comments