@@ -798,22 +798,27 @@ bool Parser::parseAvailability(
798
798
if (Spec->isWildcard ())
799
799
continue ;
800
800
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)
803
808
continue ;
804
809
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);
817
822
addAttribute (Attr);
818
823
819
824
Attr->setIsGroupMember ();
@@ -1875,6 +1880,18 @@ Parser::parseAvailabilityMacro(SmallVectorImpl<AvailabilitySpec *> &Specs) {
1875
1880
return makeParserSuccess ();
1876
1881
}
1877
1882
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
+
1878
1895
ParserStatus Parser::parsePlatformVersionInList (StringRef AttrName,
1879
1896
llvm::SmallVector<PlatformAndVersion, 4 > &PlatformAndVersions,
1880
1897
bool &ParsedUnrecognizedPlatformName) {
@@ -1886,10 +1903,10 @@ ParserStatus Parser::parsePlatformVersionInList(StringRef AttrName,
1886
1903
return MacroStatus;
1887
1904
1888
1905
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 ;
1893
1910
1894
1911
auto Version = Spec->getRawVersion ();
1895
1912
if (Version.getSubminor ().has_value () || Version.getBuild ().has_value ()) {
0 commit comments