@@ -68,16 +68,33 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
68
68
SourceLoc PlatformLoc;
69
69
70
70
llvm::VersionTuple Version;
71
+
72
+ // For macOS Big Sur, 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
+
71
86
SourceRange VersionSrcRange;
72
87
73
88
public:
74
89
PlatformVersionConstraintAvailabilitySpec (PlatformKind Platform,
75
90
SourceLoc PlatformLoc,
76
91
llvm::VersionTuple Version,
92
+ llvm::VersionTuple RuntimeVersion,
77
93
SourceRange VersionSrcRange)
78
94
: AvailabilitySpec(AvailabilitySpecKind::PlatformVersionConstraint),
79
95
Platform (Platform),
80
96
PlatformLoc(PlatformLoc), Version(Version),
97
+ RuntimeVersion(RuntimeVersion),
81
98
VersionSrcRange(VersionSrcRange) {}
82
99
83
100
// / The required platform.
@@ -93,6 +110,11 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
93
110
llvm::VersionTuple getVersion () const { return Version; }
94
111
SourceRange getVersionSrcRange () const { return VersionSrcRange; }
95
112
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
+
96
118
SourceRange getSourceRange () const ;
97
119
98
120
void print (raw_ostream &OS, unsigned Indent) const ;
0 commit comments