File tree Expand file tree Collapse file tree 4 files changed +56
-3
lines changed Expand file tree Collapse file tree 4 files changed +56
-3
lines changed Original file line number Diff line number Diff line change @@ -147,13 +147,17 @@ class DeclAttribute : public AttributeBase {
147
147
Value : 32
148
148
);
149
149
150
- SWIFT_INLINE_BITFIELD (AvailableAttr, DeclAttribute, 8 +8 +1 +1 ,
150
+ SWIFT_INLINE_BITFIELD (AvailableAttr, DeclAttribute, 8 +8 +1 +1 + 1 + 1 ,
151
151
// / A `PlatformKind` value.
152
152
Platform : 8 ,
153
153
154
154
// / A `PlatformAgnosticAvailabilityKind` value.
155
155
PlatformAgnostic : 8 ,
156
156
157
+ // / State storage for `RenamedDeclRequest`.
158
+ HasComputedRenamedDecl : 1 ,
159
+ HasRenamedDecl : 1 ,
160
+
157
161
// / Whether this attribute was spelled `@_spi_available`.
158
162
IsSPI : 1 ,
159
163
@@ -862,6 +866,22 @@ class AvailableAttr : public DeclAttribute {
862
866
static bool classof (const DeclAttribute *DA) {
863
867
return DA->getKind () == DeclAttrKind::Available;
864
868
}
869
+
870
+ bool hasCachedRenamedDecl () const {
871
+ return Bits.AvailableAttr .HasRenamedDecl ;
872
+ }
873
+
874
+ private:
875
+ friend class RenamedDeclRequest ;
876
+
877
+ bool hasComputedRenamedDecl () const {
878
+ return Bits.AvailableAttr .HasComputedRenamedDecl ;
879
+ }
880
+
881
+ void setComputedRenamedDecl (bool hasRenamedDecl) {
882
+ Bits.AvailableAttr .HasComputedRenamedDecl = true ;
883
+ Bits.AvailableAttr .HasRenamedDecl = hasRenamedDecl;
884
+ }
865
885
};
866
886
867
887
// / Indicates that the given declaration is visible to Objective-C.
Original file line number Diff line number Diff line change @@ -4085,8 +4085,9 @@ class ConditionalRequirementsRequest
4085
4085
4086
4086
class RenamedDeclRequest
4087
4087
: public SimpleRequest<RenamedDeclRequest,
4088
- ValueDecl *(const ValueDecl *, const AvailableAttr *),
4089
- RequestFlags::Cached> {
4088
+ ValueDecl *(const ValueDecl *,
4089
+ const AvailableAttr *),
4090
+ RequestFlags::Cached | RequestFlags::SplitCached> {
4090
4091
public:
4091
4092
using SimpleRequest::SimpleRequest;
4092
4093
@@ -4098,6 +4099,8 @@ class RenamedDeclRequest
4098
4099
4099
4100
public:
4100
4101
bool isCached () const { return true ; }
4102
+ std::optional<ValueDecl *> getCachedResult () const ;
4103
+ void cacheResult (ValueDecl *value) const ;
4101
4104
};
4102
4105
4103
4106
using AvailableAttrDeclPair = std::pair<const AvailableAttr *, const Decl *>;
Original file line number Diff line number Diff line change @@ -2236,6 +2236,8 @@ AvailableAttr::AvailableAttr(
2236
2236
INIT_VER_TUPLE(Obsoleted), ObsoletedRange(ObsoletedRange) {
2237
2237
Bits.AvailableAttr .Platform = static_cast <uint8_t >(Platform);
2238
2238
Bits.AvailableAttr .PlatformAgnostic = static_cast <uint8_t >(PlatformAgnostic);
2239
+ Bits.AvailableAttr .HasComputedRenamedDecl = false ;
2240
+ Bits.AvailableAttr .HasRenamedDecl = false ;
2239
2241
Bits.AvailableAttr .IsSPI = IsSPI;
2240
2242
2241
2243
if (IsForEmbedded) {
Original file line number Diff line number Diff line change @@ -1622,6 +1622,34 @@ void ResolveRawLayoutTypeRequest::cacheResult(Type value) const {
1622
1622
}
1623
1623
}
1624
1624
1625
+ // ----------------------------------------------------------------------------//
1626
+ // RenamedDeclRequest computation.
1627
+ // ----------------------------------------------------------------------------//
1628
+
1629
+ std::optional<ValueDecl *> RenamedDeclRequest::getCachedResult () const {
1630
+ auto decl = std::get<0 >(getStorage ());
1631
+ auto attr = std::get<1 >(getStorage ());
1632
+
1633
+ if (attr->hasComputedRenamedDecl ()) {
1634
+ if (attr->hasCachedRenamedDecl ())
1635
+ return decl->getASTContext ().evaluator .getCachedNonEmptyOutput (*this );
1636
+
1637
+ return nullptr ;
1638
+ }
1639
+
1640
+ return std::nullopt;
1641
+ }
1642
+
1643
+ void RenamedDeclRequest::cacheResult (ValueDecl *value) const {
1644
+ auto decl = std::get<0 >(getStorage ());
1645
+ auto attr = const_cast <AvailableAttr *>(std::get<1 >(getStorage ()));
1646
+
1647
+ attr->setComputedRenamedDecl (value != nullptr );
1648
+ if (value)
1649
+ decl->getASTContext ().evaluator .cacheNonEmptyOutput (*this ,
1650
+ std::move (value));
1651
+ }
1652
+
1625
1653
// ----------------------------------------------------------------------------//
1626
1654
// TypeCheckSourceFileRequest computation.
1627
1655
// ----------------------------------------------------------------------------//
You can’t perform that action at this time.
0 commit comments