Skip to content

Commit 429017f

Browse files
committed
[ClangImporter] Import unavailable decls as unavailable
1 parent f536a58 commit 429017f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,18 +1817,27 @@ static void applyAvailableAttribute(Decl *decl, AvailabilityContext &info,
18171817
if (info.isAlwaysAvailable())
18181818
return;
18191819

1820+
PlatformAgnosticAvailabilityKind platformAgnosticAvailability;
1821+
llvm::VersionTuple introducedVersion;
1822+
if (info.isKnownUnreachable()) {
1823+
platformAgnosticAvailability = PlatformAgnosticAvailabilityKind::Unavailable;
1824+
} else {
1825+
platformAgnosticAvailability = PlatformAgnosticAvailabilityKind::None;
1826+
introducedVersion = info.getOSVersion().getLowerEndpoint();
1827+
}
1828+
18201829
llvm::VersionTuple noVersion;
18211830
auto AvAttr = new (C) AvailableAttr(SourceLoc(), SourceRange(),
18221831
targetPlatform(C.LangOpts),
18231832
/*Message=*/StringRef(),
18241833
/*Rename=*/StringRef(),
1825-
info.getOSVersion().getLowerEndpoint(),
1834+
introducedVersion,
18261835
/*IntroducedRange*/SourceRange(),
18271836
/*Deprecated=*/noVersion,
18281837
/*DeprecatedRange*/SourceRange(),
18291838
/*Obsoleted=*/noVersion,
18301839
/*ObsoletedRange*/SourceRange(),
1831-
PlatformAgnosticAvailabilityKind::None,
1840+
platformAgnosticAvailability,
18321841
/*Implicit=*/false);
18331842

18341843
decl->getAttrs().add(AvAttr);

0 commit comments

Comments
 (0)