@@ -9186,6 +9186,34 @@ void ClangImporter::Implementation::importAttributes(
91869186 MappedDecl->getAttrs ().add (AvAttr);
91879187 }
91889188
9189+ // __attribute__((availability(domain:)))
9190+ //
9191+ if (auto avail = dyn_cast<clang::DomainAvailabilityAttr>(*AI)) {
9192+ auto *declContext = MappedDecl->getInnermostDeclContext ();
9193+
9194+ // FIXME: [availability] Don't look up the availability domain. Clang
9195+ // should be serializing the resolved VarDecl for the availability domain
9196+ // it found when type checking the attribute.
9197+ auto domainIdentifier = SwiftContext.getIdentifier (avail->getDomain ());
9198+ llvm::SmallVector<AvailabilityDomain, 4 > results;
9199+ declContext->lookupAvailabilityDomains (domainIdentifier, results);
9200+
9201+ if (results.size () > 0 ) {
9202+ // FIXME: [availability] Diagnose ambiguous availabilty domain name?
9203+ auto AttrKind = avail->getUnavailable ()
9204+ ? AvailableAttr::Kind::Unavailable
9205+ : AvailableAttr::Kind::Default;
9206+
9207+ auto avAttr = new (C) AvailableAttr (
9208+ SourceLoc (), SourceRange (), results.front (), SourceLoc (), AttrKind,
9209+ /* Message=*/ " " , /* Rename=*/ " " , /* Introduced=*/ {}, SourceRange (),
9210+ /* Deprecated=*/ {}, SourceRange (), /* Obsoleted=*/ {}, SourceRange (),
9211+ /* Implicit=*/ false , /* IsSPI=*/ false );
9212+
9213+ MappedDecl->getAttrs ().add (avAttr);
9214+ }
9215+ }
9216+
91899217 // __attribute__((swift_attr("attribute"))) are handled by
91909218 // importSwiftAttrAttributes(). Other attributes are ignored.
91919219 }
0 commit comments