@@ -223,7 +223,7 @@ AvailabilityContext::getAvailabilityRange(AvailabilityDomain domain,
223
223
const ASTContext &ctx) const {
224
224
DEBUG_ASSERT (domain.supportsContextRefinement ());
225
225
226
- if (domain.isActive (ctx) && domain. isPlatform ( ))
226
+ if (domain.isActivePlatform (ctx))
227
227
return storage->platformRange ;
228
228
229
229
for (auto domainInfo : storage->getDomainInfos ()) {
@@ -287,8 +287,9 @@ void AvailabilityContext::constrainWithPlatformRange(
287
287
void AvailabilityContext::constrainWithAvailabilityRange (
288
288
const AvailabilityRange &range, AvailabilityDomain domain,
289
289
const ASTContext &ctx) {
290
+ DEBUG_ASSERT (domain.supportsContextRefinement ());
290
291
291
- if (domain.isActive (ctx) && domain. isPlatform ( )) {
292
+ if (domain.isActivePlatform (ctx)) {
292
293
constrainWithPlatformRange (range, ctx);
293
294
return ;
294
295
}
@@ -344,7 +345,7 @@ void AvailabilityContext::constrainWithDeclAndPlatformRange(
344
345
break ;
345
346
case AvailabilityConstraint::Reason::PotentiallyUnavailable:
346
347
if (auto introducedRange = attr.getIntroducedRange (ctx)) {
347
- if (domain.isActive (ctx) && domain. isPlatform ( )) {
348
+ if (domain.isActivePlatform (ctx)) {
348
349
isConstrained |= constrainRange (platformRange, *introducedRange);
349
350
} else {
350
351
declDomainInfos.push_back ({domain, *introducedRange});
@@ -403,12 +404,35 @@ void AvailabilityContext::print(llvm::raw_ostream &os) const {
403
404
os << " version=" << stringForAvailability (getPlatformRange ());
404
405
405
406
auto domainInfos = storage->getDomainInfos ();
406
- if (domainInfos.size () > 0 ) {
407
- os << " unavailable=" ;
408
- llvm::interleave (
409
- domainInfos, os,
410
- [&](const DomainInfo &domainInfo) { domainInfo.getDomain ().print (os); },
411
- " ," );
407
+ if (!domainInfos.empty ()) {
408
+ auto availableInfos = llvm::make_filter_range (
409
+ domainInfos, [](auto info) { return !info.isUnavailable (); });
410
+
411
+ if (!availableInfos.empty ()) {
412
+ os << " available=" ;
413
+ llvm::interleave (
414
+ availableInfos, os,
415
+ [&](const DomainInfo &domainInfo) {
416
+ domainInfo.getDomain ().print (os);
417
+ if (domainInfo.getDomain ().isVersioned () &&
418
+ domainInfo.getRange ().hasMinimumVersion ())
419
+ os << " >=" << domainInfo.getRange ().getAsString ();
420
+ },
421
+ " ," );
422
+ }
423
+
424
+ auto unavailableInfos = llvm::make_filter_range (
425
+ domainInfos, [](auto info) { return info.isUnavailable (); });
426
+
427
+ if (!unavailableInfos.empty ()) {
428
+ os << " unavailable=" ;
429
+ llvm::interleave (
430
+ unavailableInfos, os,
431
+ [&](const DomainInfo &domainInfo) {
432
+ domainInfo.getDomain ().print (os);
433
+ },
434
+ " ," );
435
+ }
412
436
}
413
437
414
438
if (isDeprecated ())
0 commit comments