@@ -216,8 +216,7 @@ class UnavailabilityReason {
216
216
bool requiresDeploymentTargetOrEarlier (ASTContext &Ctx) const ;
217
217
};
218
218
219
- // / Represents everything that a particular chunk of code may assume about its
220
- // / runtime environment.
219
+ // / Represents a version range in which something is available.
221
220
// /
222
221
// / The AvailabilityContext structure forms a [lattice][], which allows it to
223
222
// / have meaningful union and intersection operations ("join" and "meet"),
@@ -229,11 +228,10 @@ class UnavailabilityReason {
229
228
// / NOTE: Generally you should use the utilities on \c AvailabilityInference
230
229
// / to create an \c AvailabilityContext, rather than creating one directly.
231
230
class AvailabilityContext {
232
- VersionRange OSVersion ;
231
+ VersionRange Range ;
233
232
234
233
public:
235
- // / Creates a context that requires certain versions of the target OS.
236
- explicit AvailabilityContext (VersionRange OSVersion) : OSVersion(OSVersion) {}
234
+ explicit AvailabilityContext (VersionRange Range) : Range(Range) {}
237
235
238
236
// / Creates a context that imposes the constraints of the ASTContext's
239
237
// / deployment target.
@@ -261,21 +259,21 @@ class AvailabilityContext {
261
259
return AvailabilityContext (VersionRange::empty ());
262
260
}
263
261
264
- // / Returns the range of possible OS versions required by this context.
265
- VersionRange getOSVersion () const { return OSVersion ; }
262
+ // / Returns the range of possible versions required by this context.
263
+ VersionRange getVersionRange () const { return Range ; }
266
264
267
265
// / Returns true if \p other makes stronger guarantees than this context.
268
266
// /
269
267
// / That is, `a.isContainedIn(b)` implies `a.union(b) == b`.
270
268
bool isContainedIn (const AvailabilityContext &other) const {
271
- return OSVersion .isContainedIn (other.OSVersion );
269
+ return Range .isContainedIn (other.Range );
272
270
}
273
271
274
272
// / Returns true if \p other is a strict subset of this context.
275
273
// /
276
274
// / That is, `a.isSupersetOf(b)` implies `a != b` and `a.union(b) == a`.
277
275
bool isSupersetOf (const AvailabilityContext &other) const {
278
- return OSVersion .isSupersetOf (other.OSVersion );
276
+ return Range .isSupersetOf (other.Range );
279
277
}
280
278
281
279
// / Returns true if this context has constraints that make it impossible to
@@ -284,13 +282,13 @@ class AvailabilityContext {
284
282
// / For example, the else branch of a `#available` check for iOS 8.0 when the
285
283
// / containing function already requires iOS 9.
286
284
bool isKnownUnreachable () const {
287
- return OSVersion .isEmpty ();
285
+ return Range .isEmpty ();
288
286
}
289
287
290
288
// / Returns true if there are no constraints on this context; that is,
291
289
// / nothing can be assumed.
292
290
bool isAlwaysAvailable () const {
293
- return OSVersion .isAll ();
291
+ return Range .isAll ();
294
292
}
295
293
296
294
// / Produces an under-approximation of the intersection of the two
@@ -303,7 +301,7 @@ class AvailabilityContext {
303
301
// / As an example, this is used when figuring out the required availability
304
302
// / for a type that references multiple nominal decls.
305
303
void intersectWith (const AvailabilityContext &other) {
306
- OSVersion .intersectWith (other.getOSVersion () );
304
+ Range .intersectWith (other.Range );
307
305
}
308
306
309
307
// / Produces an over-approximation of the intersection of the two
@@ -314,7 +312,7 @@ class AvailabilityContext {
314
312
// /
315
313
// / As an example, this is used for the true branch of `#available`.
316
314
void constrainWith (const AvailabilityContext &other) {
317
- OSVersion .constrainWith (other.getOSVersion () );
315
+ Range .constrainWith (other.Range );
318
316
}
319
317
320
318
// / Produces an over-approximation of the union of two availability contexts.
@@ -326,12 +324,12 @@ class AvailabilityContext {
326
324
// / As an example, this is used for the else branch of a conditional with
327
325
// / multiple `#available` checks.
328
326
void unionWith (const AvailabilityContext &other) {
329
- OSVersion .unionWith (other.getOSVersion () );
327
+ Range .unionWith (other.Range );
330
328
}
331
329
332
330
// / Returns a representation of this range as a string for debugging purposes.
333
331
std::string getAsString () const {
334
- return " AvailabilityContext(" + OSVersion .getAsString () + " )" ;
332
+ return " AvailabilityContext(" + Range .getAsString () + " )" ;
335
333
}
336
334
};
337
335
0 commit comments