@@ -94,6 +94,19 @@ class AvailabilitySpec : public ASTAllocated<AvailabilitySpec> {
94
94
llvm::VersionTuple version,
95
95
SourceRange versionRange);
96
96
97
+ // / Creates an availability specification that guards execution based on the
98
+ // / run-time platform and version, e.g., macOS >= 10.10.
99
+ static AvailabilitySpec *createPlatformVersioned (ASTContext &ctx,
100
+ PlatformKind platform,
101
+ SourceLoc platformLoc,
102
+ llvm::VersionTuple version,
103
+ SourceRange versionRange);
104
+
105
+ AvailabilitySpec *clone (ASTContext &ctx) const {
106
+ return new (ctx)
107
+ AvailabilitySpec (Kind, Domain, SrcRange, Version, VersionStartLoc);
108
+ }
109
+
97
110
AvailabilitySpecKind getKind () const { return Kind; }
98
111
99
112
bool isWildcard () { return getKind () == AvailabilitySpecKind::Wildcard; }
@@ -112,6 +125,11 @@ class AvailabilitySpec : public ASTAllocated<AvailabilitySpec> {
112
125
// The platform version to compare against.
113
126
llvm::VersionTuple getVersion () const ;
114
127
128
+ // The version to be used in codegen for version comparisons at run time.
129
+ // This is required to support beta versions of macOS Big Sur that
130
+ // report 10.16 at run time.
131
+ llvm::VersionTuple getRuntimeVersion () const { return Version; }
132
+
115
133
SourceRange getVersionSrcRange () const {
116
134
if (!VersionStartLoc)
117
135
return SourceRange ();
@@ -123,44 +141,6 @@ class AvailabilitySpec : public ASTAllocated<AvailabilitySpec> {
123
141
void setMacroLoc (SourceLoc loc) { MacroLoc = loc; }
124
142
};
125
143
126
- // / An availability specification that guards execution based on the
127
- // / run-time platform and version, e.g., OS X >= 10.10.
128
- class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
129
- static std::optional<AvailabilityDomain>
130
- getDomainForPlatform (PlatformKind Platform) {
131
- if (Platform != PlatformKind::none)
132
- return AvailabilityDomain::forPlatform (Platform);
133
- return std::nullopt;
134
- }
135
-
136
- public:
137
- PlatformVersionConstraintAvailabilitySpec (PlatformKind Platform,
138
- SourceLoc PlatformLoc,
139
- llvm::VersionTuple Version,
140
- SourceRange VersionSrcRange)
141
- : AvailabilitySpec(AvailabilitySpecKind::PlatformVersionConstraint,
142
- getDomainForPlatform (Platform),
143
- SourceRange(PlatformLoc, VersionSrcRange.End), Version,
144
- VersionSrcRange.Start) {}
145
- // The version to be used in codegen for version comparisons at run time.
146
- // This is required to support beta versions of macOS Big Sur that
147
- // report 10.16 at run time.
148
- llvm::VersionTuple getRuntimeVersion () const ;
149
-
150
- void print (raw_ostream &OS, unsigned Indent) const ;
151
-
152
- static bool classof (const AvailabilitySpec *Spec) {
153
- return Spec->getKind () == AvailabilitySpecKind::PlatformVersionConstraint;
154
- }
155
-
156
- void *
157
- operator new (size_t Bytes, ASTContext &C,
158
- unsigned Alignment = alignof(PlatformVersionConstraintAvailabilitySpec)){
159
- return AvailabilitySpec::operator new (Bytes, C, AllocationArena::Permanent,
160
- Alignment);
161
- }
162
- };
163
-
164
144
// / Maps of macro name and version to availability specifications.
165
145
// / Organized as two nested \c DenseMap keyed first on the macro name then
166
146
// / the macro version. This structure allows to peek at macro names before
0 commit comments