Skip to content

Commit a82e999

Browse files
committed
[ClangImporter] Fix isUnavailableInSwift on non-Apple platforms.
Don't bail out early when there's no deprecated-as-unavailable mode; we also use the loop to check for `availability(swift, unavailable)`. No test because the only callers are for Objective-C declarations.
1 parent cc28774 commit a82e999

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/ClangImporter/ClangAdapter.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -671,15 +671,9 @@ bool importer::isUnavailableInSwift(
671671
if (enableObjCInterop && isObjCId(decl))
672672
return true;
673673

674-
// FIXME: Somewhat duplicated from importAttributes(), but this is a
675-
// more direct path.
676-
if (decl->getAvailability() == clang::AR_Unavailable)
674+
if (decl->isUnavailable())
677675
return true;
678676

679-
// Apply the deprecated-as-unavailable filter.
680-
if (!platformAvailability.deprecatedAsUnavailableFilter)
681-
return false;
682-
683677
for (auto *attr : decl->specific_attrs<clang::AvailabilityAttr>()) {
684678
if (attr->getPlatform()->getName() == "swift")
685679
return true;
@@ -689,12 +683,15 @@ bool importer::isUnavailableInSwift(
689683
continue;
690684
}
691685

692-
clang::VersionTuple version = attr->getDeprecated();
693-
if (version.empty())
694-
continue;
695-
if (platformAvailability.deprecatedAsUnavailableFilter(version.getMajor(),
696-
version.getMinor()))
697-
return true;
686+
if (platformAvailability.deprecatedAsUnavailableFilter) {
687+
clang::VersionTuple version = attr->getDeprecated();
688+
if (version.empty())
689+
continue;
690+
if (platformAvailability.deprecatedAsUnavailableFilter(
691+
version.getMajor(), version.getMinor())) {
692+
return true;
693+
}
694+
}
698695
}
699696

700697
return false;

0 commit comments

Comments
 (0)