@@ -37,8 +37,7 @@ static bool constrainRange(AvailabilityRange &existing,
37
37
return true ;
38
38
}
39
39
40
- bool AvailabilityContext::PlatformInfo::constrainWith (
41
- const PlatformInfo &other) {
40
+ bool AvailabilityContext::Info::constrainWith (const Info &other) {
42
41
bool isConstrained = false ;
43
42
isConstrained |= constrainRange (Range, other.Range );
44
43
if (other.IsUnavailable ) {
@@ -51,7 +50,7 @@ bool AvailabilityContext::PlatformInfo::constrainWith(
51
50
return isConstrained;
52
51
}
53
52
54
- bool AvailabilityContext::PlatformInfo ::constrainWith (const Decl *decl) {
53
+ bool AvailabilityContext::Info ::constrainWith (const Decl *decl) {
55
54
bool isConstrained = false ;
56
55
57
56
if (auto range = AvailabilityInference::annotatedAvailableRange (decl))
@@ -68,7 +67,7 @@ bool AvailabilityContext::PlatformInfo::constrainWith(const Decl *decl) {
68
67
return isConstrained;
69
68
}
70
69
71
- bool AvailabilityContext::PlatformInfo ::constrainUnavailability (
70
+ bool AvailabilityContext::Info ::constrainUnavailability (
72
71
std::optional<PlatformKind> unavailablePlatform) {
73
72
if (!unavailablePlatform)
74
73
return false ;
@@ -94,8 +93,7 @@ bool AvailabilityContext::PlatformInfo::constrainUnavailability(
94
93
return true ;
95
94
}
96
95
97
- bool AvailabilityContext::PlatformInfo::isContainedIn (
98
- const PlatformInfo &other) const {
96
+ bool AvailabilityContext::Info::isContainedIn (const Info &other) const {
99
97
if (!Range.isContainedIn (other.Range ))
100
98
return false ;
101
99
@@ -120,17 +118,17 @@ bool AvailabilityContext::PlatformInfo::isContainedIn(
120
118
}
121
119
122
120
void AvailabilityContext::Storage::Profile (llvm::FoldingSetNodeID &id) const {
123
- Platform .Profile (id);
121
+ info .Profile (id);
124
122
}
125
123
126
124
AvailabilityContext
127
125
AvailabilityContext::forPlatformRange (const AvailabilityRange &range,
128
126
ASTContext &ctx) {
129
- PlatformInfo platformInfo {range, PlatformKind::none,
130
- /* IsUnavailable*/ false ,
131
- /* IsUnavailableInEmbedded*/ false ,
132
- /* IsDeprecated*/ false };
133
- return AvailabilityContext (Storage::get (platformInfo , ctx));
127
+ Info info {range, PlatformKind::none,
128
+ /* IsUnavailable*/ false ,
129
+ /* IsUnavailableInEmbedded*/ false ,
130
+ /* IsDeprecated*/ false };
131
+ return AvailabilityContext (Storage::get (info , ctx));
134
132
}
135
133
136
134
AvailabilityContext AvailabilityContext::forInliningTarget (ASTContext &ctx) {
@@ -147,40 +145,44 @@ AvailabilityContext
147
145
AvailabilityContext::get (const AvailabilityRange &platformAvailability,
148
146
std::optional<PlatformKind> unavailablePlatform,
149
147
bool deprecated, ASTContext &ctx) {
150
- PlatformInfo platformInfo{platformAvailability,
151
- unavailablePlatform.has_value ()
152
- ? *unavailablePlatform
153
- : PlatformKind::none,
154
- unavailablePlatform.has_value (),
155
- /* IsUnavailableInEmbedded*/ false , deprecated};
156
- return AvailabilityContext (Storage::get (platformInfo, ctx));
148
+ Info info{platformAvailability,
149
+ unavailablePlatform.has_value () ? *unavailablePlatform
150
+ : PlatformKind::none,
151
+ unavailablePlatform.has_value (),
152
+ /* IsUnavailableInEmbedded*/ false , deprecated};
153
+ return AvailabilityContext (Storage::get (info, ctx));
157
154
}
158
155
159
156
AvailabilityRange AvailabilityContext::getPlatformRange () const {
160
- return Info-> Platform .Range ;
157
+ return storage-> info .Range ;
161
158
}
162
159
163
160
std::optional<PlatformKind>
164
161
AvailabilityContext::getUnavailablePlatformKind () const {
165
- if (Info-> Platform .IsUnavailable )
166
- return Info-> Platform .UnavailablePlatform ;
162
+ if (storage-> info .IsUnavailable )
163
+ return storage-> info .UnavailablePlatform ;
167
164
return std::nullopt;
168
165
}
169
166
170
167
bool AvailabilityContext::isUnavailableInEmbedded () const {
171
- return Info-> Platform .IsUnavailableInEmbedded ;
168
+ return storage-> info .IsUnavailableInEmbedded ;
172
169
}
173
170
174
171
bool AvailabilityContext::isDeprecated () const {
175
- return Info-> Platform .IsDeprecated ;
172
+ return storage-> info .IsDeprecated ;
176
173
}
177
174
178
175
void AvailabilityContext::constrainWithContext (const AvailabilityContext &other,
179
176
ASTContext &ctx) {
180
- PlatformInfo platformAvailability{Info->Platform };
181
- if (platformAvailability.constrainWith (other.Info ->Platform )) {
182
- Info = Storage::get (platformAvailability, ctx);
183
- }
177
+ bool isConstrained = false ;
178
+
179
+ Info info{storage->info };
180
+ isConstrained |= info.constrainWith (other.storage ->info );
181
+
182
+ if (!isConstrained)
183
+ return ;
184
+
185
+ storage = Storage::get (info, ctx);
184
186
}
185
187
186
188
void AvailabilityContext::constrainWithDecl (const Decl *decl) {
@@ -189,28 +191,30 @@ void AvailabilityContext::constrainWithDecl(const Decl *decl) {
189
191
190
192
void AvailabilityContext::constrainWithPlatformRange (
191
193
const AvailabilityRange &platformRange, ASTContext &ctx) {
192
- PlatformInfo platformAvailability{Info->Platform };
193
- if (!constrainRange (platformAvailability.Range , platformRange))
194
+
195
+ Info info{storage->info };
196
+ if (!constrainRange (info.Range , platformRange))
194
197
return ;
195
198
196
- Info = Storage::get (platformAvailability , ctx);
199
+ storage = Storage::get (info , ctx);
197
200
}
198
201
199
202
void AvailabilityContext::constrainWithDeclAndPlatformRange (
200
203
const Decl *decl, const AvailabilityRange &platformRange) {
201
- PlatformInfo platformAvailability{Info->Platform };
202
204
bool isConstrained = false ;
203
- isConstrained |= platformAvailability.constrainWith (decl);
204
- isConstrained |= constrainRange (platformAvailability.Range , platformRange);
205
+
206
+ Info info{storage->info };
207
+ isConstrained |= info.constrainWith (decl);
208
+ isConstrained |= constrainRange (info.Range , platformRange);
205
209
206
210
if (!isConstrained)
207
211
return ;
208
212
209
- Info = Storage::get (platformAvailability , decl->getASTContext ());
213
+ storage = Storage::get (info , decl->getASTContext ());
210
214
}
211
215
212
216
bool AvailabilityContext::isContainedIn (const AvailabilityContext other) const {
213
- if (!Info-> Platform .isContainedIn (other.Info -> Platform ))
217
+ if (!storage-> info .isContainedIn (other.storage -> info ))
214
218
return false ;
215
219
216
220
return true ;
0 commit comments