@@ -9186,6 +9186,34 @@ void ClangImporter::Implementation::importAttributes(
9186
9186
MappedDecl->getAttrs().add(AvAttr);
9187
9187
}
9188
9188
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
+
9189
9217
// __attribute__((swift_attr("attribute"))) are handled by
9190
9218
// importSwiftAttrAttributes(). Other attributes are ignored.
9191
9219
}
0 commit comments