File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -350,15 +350,20 @@ class AvailabilityInference {
350
350
351
351
static AvailabilityRange inferForType (Type t);
352
352
353
- // / Returns the context where a declaration is available
354
- // / We assume a declaration without an annotation is always available.
353
+ // / Returns the range of platform versions in which the decl is available.
355
354
static AvailabilityRange availableRange (const Decl *D);
356
355
356
+ // / Returns the range of platform versions in which the decl is available and
357
+ // / the attribute which determined this range (which may be `nullptr` if the
358
+ // / declaration is always available.
359
+ static std::pair<AvailabilityRange, const AvailableAttr *>
360
+ availableRangeAndAttr (const Decl *D);
361
+
357
362
// / Returns true is the declaration is `@_spi_available`.
358
363
static bool isAvailableAsSPI (const Decl *D);
359
364
360
- // / Returns the availability context for a declaration with the given
361
- // / @available attribute.
365
+ // / Returns the range of platform versions in which a declaration with the
366
+ // / given ` @available` attribute is available .
362
367
// /
363
368
// / NOTE: The attribute must be active on the current platform.
364
369
static AvailabilityRange availableRange (const AvailableAttr *attr,
Original file line number Diff line number Diff line change @@ -580,12 +580,18 @@ static const AvailableAttr *attrForAvailableRange(const Decl *D) {
580
580
return nullptr ;
581
581
}
582
582
583
- AvailabilityRange AvailabilityInference::availableRange (const Decl *D) {
584
- if (auto attr = attrForAvailableRange (D))
585
- return availableRange (attr, D->getASTContext ());
583
+ std::pair<AvailabilityRange, const AvailableAttr *>
584
+ AvailabilityInference::availableRangeAndAttr (const Decl *D) {
585
+ if (auto attr = attrForAvailableRange (D)) {
586
+ return {availableRange (attr, D->getASTContext ()), attr};
587
+ }
586
588
587
589
// Treat unannotated declarations as always available.
588
- return AvailabilityRange::alwaysAvailable ();
590
+ return {AvailabilityRange::alwaysAvailable (), nullptr };
591
+ }
592
+
593
+ AvailabilityRange AvailabilityInference::availableRange (const Decl *D) {
594
+ return availableRangeAndAttr (D).first ;
589
595
}
590
596
591
597
bool AvailabilityInference::isAvailableAsSPI (const Decl *D) {
You can’t perform that action at this time.
0 commit comments