@@ -289,6 +289,12 @@ class AvailabilityDomain final {
289
289
return getRemappedDomain (ctx, unused);
290
290
}
291
291
292
+ // / Returns true for a domain that is permanently always available, and
293
+ // / therefore availability constraints in the domain are effectively the same
294
+ // / as constraints in the `*` domain. This is used to diagnose unnecessary
295
+ // / `@available` attributes and `if #available` statements.
296
+ bool isPermanentlyAlwaysEnabled () const ;
297
+
292
298
bool operator ==(const AvailabilityDomain &other) const {
293
299
return storage.getOpaqueValue () == other.storage .getOpaqueValue ();
294
300
}
@@ -330,7 +336,7 @@ struct StableAvailabilityDomainComparator {
330
336
// / Represents an availability domain that has been defined in a module.
331
337
class CustomAvailabilityDomain : public llvm ::FoldingSetNode {
332
338
public:
333
- enum class Kind {
339
+ enum class Kind : uint8_t {
334
340
// / A domain that is known to be enabled at compile time.
335
341
Enabled,
336
342
// / A domain that is known to be enabled at compile time and is also assumed
@@ -344,10 +350,20 @@ class CustomAvailabilityDomain : public llvm::FoldingSetNode {
344
350
345
351
private:
346
352
Identifier name;
347
- Kind kind;
348
353
ModuleDecl *mod;
349
354
ValueDecl *decl;
350
355
FuncDecl *predicateFunc;
356
+ Kind kind;
357
+
358
+ struct {
359
+ // / Whether the "isPermanentlyEnabled" bit has been computed yet.
360
+ unsigned isPermanentlyEnabledComputed : 1 ;
361
+ // / Whether the domain is permanently enabled, which makes constraints in
362
+ // / the domain equivalent to those in the `*` domain.
363
+ unsigned isPermanentlyEnabled : 1 ;
364
+ } flags = {};
365
+
366
+ friend class IsCustomAvailabilityDomainPermanentlyEnabled ;
351
367
352
368
CustomAvailabilityDomain (Identifier name, Kind kind, ModuleDecl *mod,
353
369
ValueDecl *decl, FuncDecl *predicateFunc);
@@ -375,6 +391,11 @@ class CustomAvailabilityDomain : public llvm::FoldingSetNode {
375
391
void Profile (llvm::FoldingSetNodeID &ID) const { Profile (ID, name, mod); }
376
392
};
377
393
394
+ inline void simple_display (llvm::raw_ostream &os,
395
+ const CustomAvailabilityDomain *domain) {
396
+ os << domain->getName ();
397
+ }
398
+
378
399
// / Represents either a resolved availability domain or an identifier written
379
400
// / in source that has not yet been resolved to a domain.
380
401
class AvailabilityDomainOrIdentifier {
0 commit comments