@@ -44,19 +44,24 @@ void AvailabilityConstraint::print(llvm::raw_ostream &os) const {
44
44
getAttr ().getDomain ().print (os);
45
45
os << " , " ;
46
46
47
+ std::optional<llvm::VersionTuple> version;
47
48
switch (getReason ()) {
48
49
case Reason::UnavailableUnconditionally:
49
50
os << " unavailable" ;
50
51
break ;
51
52
case Reason::UnavailableObsolete:
52
- os << " obsoleted: " << getAttr ().getObsoleted ().value ();
53
+ os << " obsoleted" ;
54
+ version = getAttr ().getObsoleted ();
53
55
break ;
54
56
case Reason::UnavailableUnintroduced:
55
57
case Reason::Unintroduced:
56
- os << " introduced: " << getAttr ().getIntroduced ().value ();
58
+ os << " introduced" ;
59
+ version = getAttr ().getIntroduced ();
57
60
break ;
58
61
}
59
62
63
+ if (version)
64
+ os << " : " << *version;
60
65
os << " )" ;
61
66
}
62
67
@@ -219,26 +224,23 @@ getAvailabilityConstraintForAttr(const Decl *decl,
219
224
auto &ctx = decl->getASTContext ();
220
225
auto domain = attr.getDomain ();
221
226
auto deploymentRange = domain.getDeploymentRange (ctx);
227
+ bool domainSupportsRefinement = domain.supportsContextRefinement ();
228
+ std::optional<AvailabilityRange> availableRange =
229
+ domainSupportsRefinement ? context.getAvailabilityRange (domain, ctx)
230
+ : deploymentRange;
222
231
223
- // Is the decl obsoleted in the deployment context?
232
+ // Is the decl obsoleted in this context?
224
233
if (auto obsoletedRange = attr.getObsoletedRange (ctx)) {
225
- if (deploymentRange && deploymentRange ->isContainedIn (*obsoletedRange))
234
+ if (availableRange && availableRange ->isContainedIn (*obsoletedRange))
226
235
return AvailabilityConstraint::unavailableObsolete (attr);
227
236
}
228
237
229
- // Is the decl not yet introduced in the local context?
238
+ // Is the decl not yet introduced in this context?
230
239
if (auto introducedRange = attr.getIntroducedRange (ctx)) {
231
- if (domain.supportsContextRefinement ()) {
232
- auto availableRange = context.getAvailabilityRange (domain, ctx);
233
- if (!availableRange || !availableRange->isContainedIn (*introducedRange))
234
- return AvailabilityConstraint::unintroduced (attr);
235
-
236
- return std::nullopt;
237
- }
238
-
239
- // Is the decl not yet introduced in the deployment context?
240
- if (deploymentRange && !deploymentRange->isContainedIn (*introducedRange))
241
- return AvailabilityConstraint::unavailableUnintroduced (attr);
240
+ if (!availableRange || !availableRange->isContainedIn (*introducedRange))
241
+ return domainSupportsRefinement
242
+ ? AvailabilityConstraint::unintroduced (attr)
243
+ : AvailabilityConstraint::unavailableUnintroduced (attr);
242
244
}
243
245
244
246
return std::nullopt;
0 commit comments