@@ -151,10 +151,14 @@ class DeclAttribute : public AttributeBase {
151151 Value : 32
152152 );
153153
154- SWIFT_INLINE_BITFIELD (AvailableAttr, DeclAttribute, 4 +1 +1 +1 ,
154+ SWIFT_INLINE_BITFIELD (AvailableAttr, DeclAttribute, 4 +1 +1 +1 + 1 + 1 ,
155155 // / An `AvailableAttr::Kind` value.
156156 Kind : 4 ,
157157
158+ // / State storage for `SemanticAvailableAttrRequest`.
159+ HasComputedSemanticAttr : 1 ,
160+ HasDomain : 1 ,
161+
158162 // / State storage for `RenamedDeclRequest`.
159163 HasComputedRenamedDecl : 1 ,
160164 HasRenamedDecl : 1 ,
@@ -806,14 +810,15 @@ class AvailableAttr : public DeclAttribute {
806810 // / Returns the `AvailabilityDomain` associated with the attribute, or
807811 // / `std::nullopt` if it has either not yet been resolved or could not be
808812 // / resolved successfully.
809- std::optional<AvailabilityDomain> getCachedDomain () const { return Domain; }
813+ std::optional<AvailabilityDomain> getCachedDomain () const {
814+ if (hasCachedDomain ())
815+ return Domain;
816+ return std::nullopt ;
817+ }
810818
811819 // / Returns true if the `AvailabilityDomain` associated with the attribute
812820 // / has been resolved successfully.
813- bool hasCachedDomain () const {
814- // For now, domains are always set on construction of the attribute.
815- return true ;
816- }
821+ bool hasCachedDomain () const { return Bits.AvailableAttr .HasDomain ; }
817822
818823 // / Returns the kind of availability the attribute specifies.
819824 Kind getKind () const { return static_cast <Kind>(Bits.AvailableAttr .Kind ); }
@@ -873,6 +878,17 @@ class AvailableAttr : public DeclAttribute {
873878 Bits.AvailableAttr .HasComputedRenamedDecl = true ;
874879 Bits.AvailableAttr .HasRenamedDecl = hasRenamedDecl;
875880 }
881+
882+ private:
883+ friend class SemanticAvailableAttrRequest ;
884+
885+ bool hasComputedSemanticAttr () const {
886+ return Bits.AvailableAttr .HasComputedSemanticAttr ;
887+ }
888+
889+ void setComputedSemanticAttr () {
890+ Bits.AvailableAttr .HasComputedSemanticAttr = true ;
891+ }
876892};
877893
878894// / Indicates that the given declaration is visible to Objective-C.
0 commit comments