AST: Clean up AvailabilityContext and uses
#76203
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the purposes of availability calculations, direct use of
llvm::VersionTupleandVersionRangeis discouraged, since these fundamental version representations are divorced from their context. For example, comparing an iOS platform version to a visionOS platform version is invalid since the versioning systems of the two platforms differ. Although visionOS inherits avialability from iOS, an iOS version must be converted to a visionOS version prior to comparison. In the future,AvailabilityContextcan be enriched to carry the information necessary to verify that its algebraic operations are being performed on compatible values.Other notable changes:
IsSPIfromAvailabilityContext. It only existed to makeDecl::isAvailableAsSPI()convenient to implement, which wasn't very good justification.AvailabilityContextsmay represent version ranges that are not tied to OS platforms.UnavailabilityReasonclass. It did not live up to its name because it only modeled potential unavailability due to an unmet OS version requirement but something can be unavailable for many other reasons, like explicit unavailability, language mode requirements, obsoletion, etc.