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 {
350350
351351 static AvailabilityRange inferForType (Type t);
352352
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.
355354 static AvailabilityRange availableRange (const Decl *D);
356355
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+
357362 // / Returns true is the declaration is `@_spi_available`.
358363 static bool isAvailableAsSPI (const Decl *D);
359364
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 .
362367 // /
363368 // / NOTE: The attribute must be active on the current platform.
364369 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) {
580580 return nullptr ;
581581}
582582
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+ }
586588
587589 // 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 ;
589595}
590596
591597bool AvailabilityInference::isAvailableAsSPI (const Decl *D) {
You can’t perform that action at this time.
0 commit comments