@@ -289,6 +289,12 @@ class AvailabilityDomain final {
289289 return getRemappedDomain (ctx, unused);
290290 }
291291
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+
292298 bool operator ==(const AvailabilityDomain &other) const {
293299 return storage.getOpaqueValue () == other.storage .getOpaqueValue ();
294300 }
@@ -330,7 +336,7 @@ struct StableAvailabilityDomainComparator {
330336// / Represents an availability domain that has been defined in a module.
331337class CustomAvailabilityDomain : public llvm ::FoldingSetNode {
332338public:
333- enum class Kind {
339+ enum class Kind : uint8_t {
334340 // / A domain that is known to be enabled at compile time.
335341 Enabled,
336342 // / A domain that is known to be enabled at compile time and is also assumed
@@ -344,10 +350,20 @@ class CustomAvailabilityDomain : public llvm::FoldingSetNode {
344350
345351private:
346352 Identifier name;
347- Kind kind;
348353 ModuleDecl *mod;
349354 ValueDecl *decl;
350355 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 ;
351367
352368 CustomAvailabilityDomain (Identifier name, Kind kind, ModuleDecl *mod,
353369 ValueDecl *decl, FuncDecl *predicateFunc);
@@ -375,6 +391,11 @@ class CustomAvailabilityDomain : public llvm::FoldingSetNode {
375391 void Profile (llvm::FoldingSetNodeID &ID) const { Profile (ID, name, mod); }
376392};
377393
394+ inline void simple_display (llvm::raw_ostream &os,
395+ const CustomAvailabilityDomain *domain) {
396+ os << domain->getName ();
397+ }
398+
378399// / Represents either a resolved availability domain or an identifier written
379400// / in source that has not yet been resolved to a domain.
380401class AvailabilityDomainOrIdentifier {
0 commit comments