@@ -288,13 +288,6 @@ static bool shouldTreatDeclContextAsAsyncForDiagnostics(const DeclContext *DC) {
288288 return DC->isAsyncContext ();
289289}
290290
291- AvailabilityRange TypeChecker::overApproximateAvailabilityAtLocation (
292- SourceLoc loc, const DeclContext *DC,
293- const AvailabilityScope **MostRefined) {
294- return AvailabilityContext::forLocation (loc, DC, MostRefined)
295- .getPlatformRange ();
296- }
297-
298291// / A class that walks the AST to find the innermost (i.e., deepest) node that
299292// / contains a target SourceRange and matches a particular criterion.
300293// / This class finds the innermost nodes of interest by walking
@@ -689,8 +682,8 @@ static bool fixAvailabilityByNarrowingNearbyVersionCheck(
689682 return false ;
690683
691684 const AvailabilityScope *scope = nullptr ;
692- (void )TypeChecker::overApproximateAvailabilityAtLocation (ReferenceRange.Start ,
693- ReferenceDC, &scope);
685+ (void )AvailabilityContext::forLocation (ReferenceRange.Start , ReferenceDC ,
686+ &scope);
694687 if (!scope)
695688 return false ;
696689
@@ -866,7 +859,7 @@ static void diagnosePotentialUnavailability(
866859// FIXME: [availability] Should this take an AvailabilityContext instead of
867860// AvailabilityRange?
868861bool TypeChecker::checkAvailability (SourceRange ReferenceRange,
869- AvailabilityRange RequiredAvailability ,
862+ AvailabilityRange PlatformRange ,
870863 const DeclContext *ReferenceDC,
871864 llvm::function_ref<InFlightDiagnostic(
872865 AvailabilityDomain, AvailabilityRange)>
@@ -880,24 +873,25 @@ bool TypeChecker::checkAvailability(SourceRange ReferenceRange,
880873 return false ;
881874
882875 auto availabilityAtLocation =
883- TypeChecker::overApproximateAvailabilityAtLocation (ReferenceRange.Start ,
884- ReferenceDC);
885- if (!availabilityAtLocation.isContainedIn (RequiredAvailability)) {
876+ AvailabilityContext::forLocation (ReferenceRange.Start , ReferenceDC)
877+ .getPlatformRange ();
878+
879+ if (!availabilityAtLocation.isContainedIn (PlatformRange)) {
886880 diagnosePotentialUnavailability (ReferenceRange, Diagnose, ReferenceDC,
887- domain, RequiredAvailability );
881+ domain, PlatformRange );
888882 return true ;
889883 }
890884
891885 return false ;
892886}
893887
894888bool TypeChecker::checkAvailability (
895- SourceRange ReferenceRange, AvailabilityRange RequiredAvailability ,
889+ SourceRange ReferenceRange, AvailabilityRange PlatformRange ,
896890 Diag<AvailabilityDomain, AvailabilityRange> Diag,
897891 const DeclContext *ReferenceDC) {
898892 auto &Diags = ReferenceDC->getASTContext ().Diags ;
899893 return TypeChecker::checkAvailability (
900- ReferenceRange, RequiredAvailability , ReferenceDC,
894+ ReferenceRange, PlatformRange , ReferenceDC,
901895 [&](AvailabilityDomain domain, AvailabilityRange range) {
902896 return Diags.diagnose (ReferenceRange.Start , Diag, domain, range);
903897 });
@@ -1494,18 +1488,19 @@ static void diagnoseIfDeprecated(SourceRange ReferenceRange,
14941488 if (!Attr)
14951489 return ;
14961490
1491+ auto Availability = Where.getAvailability ();
1492+
14971493 // We match the behavior of clang to not report deprecation warnings
14981494 // inside declarations that are themselves deprecated on all deployment
14991495 // targets.
1500- if (Where .isDeprecated ()) {
1496+ if (Availability .isDeprecated ()) {
15011497 return ;
15021498 }
15031499
15041500 auto *ReferenceDC = Where.getDeclContext ();
15051501 auto &Context = ReferenceDC->getASTContext ();
15061502 if (!Context.LangOpts .DisableAvailabilityChecking ) {
1507- AvailabilityRange RunningOSVersions = Where.getAvailabilityRange ();
1508- if (RunningOSVersions.isKnownUnreachable ()) {
1503+ if (Availability.getPlatformRange ().isKnownUnreachable ()) {
15091504 // Suppress a deprecation warning if the availability checking machinery
15101505 // thinks the reference program location will not execute on any
15111506 // deployment target for the current platform.
@@ -1573,18 +1568,19 @@ static bool diagnoseIfDeprecated(SourceLoc loc,
15731568 if (!attr)
15741569 return false ;
15751570
1571+ auto availability = where.getAvailability ();
1572+
15761573 // We match the behavior of clang to not report deprecation warnings
15771574 // inside declarations that are themselves deprecated on all deployment
15781575 // targets.
1579- if (where .isDeprecated ()) {
1576+ if (availability .isDeprecated ()) {
15801577 return false ;
15811578 }
15821579
15831580 auto *dc = where.getDeclContext ();
15841581 auto &ctx = dc->getASTContext ();
15851582 if (!ctx.LangOpts .DisableAvailabilityChecking ) {
1586- AvailabilityRange runningOSVersion = where.getAvailabilityRange ();
1587- if (runningOSVersion.isKnownUnreachable ()) {
1583+ if (availability.getPlatformRange ().isKnownUnreachable ()) {
15881584 // Suppress a deprecation warning if the availability checking machinery
15891585 // thinks the reference program location will not execute on any
15901586 // deployment target for the current platform.
0 commit comments