@@ -68,16 +68,33 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
6868 SourceLoc PlatformLoc;
6969
7070 llvm::VersionTuple Version;
71+
72+ // For macOS Big Sur, we we canonicalize 10.16 to 11.0 for compile-time
73+ // checking since clang canonicalizes availability markup. However, to
74+ // support Beta versions of macOS Big Sur where the OS
75+ // reports 10.16 at run time, we need to compare against 10.16,
76+ //
77+ // This means for:
78+ //
79+ // if #available(macOS 10.16, *) { ... }
80+ //
81+ // we need to keep around both a canonical version for use in compile-time
82+ // checks and an uncanonicalized version for the version to actually codegen
83+ // with.
84+ llvm::VersionTuple RuntimeVersion;
85+
7186 SourceRange VersionSrcRange;
7287
7388public:
7489 PlatformVersionConstraintAvailabilitySpec (PlatformKind Platform,
7590 SourceLoc PlatformLoc,
7691 llvm::VersionTuple Version,
92+ llvm::VersionTuple RuntimeVersion,
7793 SourceRange VersionSrcRange)
7894 : AvailabilitySpec(AvailabilitySpecKind::PlatformVersionConstraint),
7995 Platform (Platform),
8096 PlatformLoc(PlatformLoc), Version(Version),
97+ RuntimeVersion(RuntimeVersion),
8198 VersionSrcRange(VersionSrcRange) {}
8299
83100 // / The required platform.
@@ -93,6 +110,11 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
93110 llvm::VersionTuple getVersion () const { return Version; }
94111 SourceRange getVersionSrcRange () const { return VersionSrcRange; }
95112
113+ // The version to be used in codegen for version comparisons at run time.
114+ // This is required to support beta versions of macOS Big Sur that
115+ // report 10.16 at run time.
116+ llvm::VersionTuple getRuntimeVersion () const { return RuntimeVersion; }
117+
96118 SourceRange getSourceRange () const ;
97119
98120 void print (raw_ostream &OS, unsigned Indent) const ;
0 commit comments