Skip to content

Commit 100a794

Browse files
committed
AST: Adopt SemanticAvailableAttr in getAvailabilityConditionVersionSourceRange().
1 parent ab9bbcc commit 100a794

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

lib/AST/AvailabilityScope.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,21 +295,19 @@ static SourceRange getAvailabilityConditionVersionSourceRange(
295295
}
296296

297297
static SourceRange
298-
getAvailabilityConditionVersionSourceRange(const DeclAttributes &DeclAttrs,
299-
PlatformKind Platform,
298+
getAvailabilityConditionVersionSourceRange(const Decl *D, PlatformKind Platform,
300299
const llvm::VersionTuple &Version) {
301300
SourceRange Range;
302-
for (auto *Attr : DeclAttrs) {
303-
if (auto *AA = dyn_cast<AvailableAttr>(Attr)) {
304-
if (AA->Introduced.has_value() && AA->Introduced.value() == Version &&
305-
AA->getPlatform() == Platform) {
301+
for (auto Attr : D->getSemanticAvailableAttrs()) {
302+
if (Attr.getIntroduced().has_value() &&
303+
Attr.getIntroduced().value() == Version &&
304+
Attr.getPlatform() == Platform) {
306305

307-
// More than one: return invalid range.
308-
if (Range.isValid())
309-
return SourceRange();
310-
else
311-
Range = AA->IntroducedRange;
312-
}
306+
// More than one: return invalid range.
307+
if (Range.isValid())
308+
return SourceRange();
309+
else
310+
Range = Attr.getParsedAttr()->IntroducedRange;
313311
}
314312
}
315313
return Range;
@@ -319,8 +317,8 @@ SourceRange AvailabilityScope::getAvailabilityConditionVersionSourceRange(
319317
PlatformKind Platform, const llvm::VersionTuple &Version) const {
320318
switch (getReason()) {
321319
case Reason::Decl:
322-
return ::getAvailabilityConditionVersionSourceRange(
323-
Node.getAsDecl()->getAttrs(), Platform, Version);
320+
return ::getAvailabilityConditionVersionSourceRange(Node.getAsDecl(),
321+
Platform, Version);
324322

325323
case Reason::IfStmtThenBranch:
326324
case Reason::IfStmtElseBranch:

0 commit comments

Comments
 (0)