Skip to content

Commit 43dfa6a

Browse files
committed
SymbolGraph: Simplify availability check.
Getting a result from `DeclAttrs::getUnavailable()` already indicates that the declaration is either fully unavailable or obsoleted. Checking `AvailableAttr::getVersionAvailability()` is redundant.
1 parent 2358712 commit 43dfa6a

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

lib/SymbolGraphGen/SymbolGraphASTWalker.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,17 @@ SymbolGraph *SymbolGraphASTWalker::getModuleSymbolGraph(const Decl *D) {
110110
return SG;
111111
}
112112

113-
namespace {
114-
bool isUnavailableOrObsoleted(const Decl *D) {
113+
static bool isUnavailableOrObsoletedOnPlatform(const Decl *D) {
115114
if (const auto *Avail =
116115
D->getAttrs().getUnavailable(D->getASTContext())) {
117-
if (Avail->getPlatform() != PlatformKind::none) {
118-
switch (Avail->getVersionAvailability(D->getASTContext())) {
119-
case AvailableVersionComparison::Unavailable:
120-
case AvailableVersionComparison::Obsoleted:
121-
return true;
122-
default:
123-
break;
124-
}
125-
}
116+
if (Avail->getPlatform() != PlatformKind::none)
117+
return true;
126118
}
127119
return false;
128120
}
129-
} // end anonymous namespace
130121

131122
bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
132-
if (isUnavailableOrObsoleted(D)) {
123+
if (isUnavailableOrObsoletedOnPlatform(D)) {
133124
return false;
134125
}
135126

@@ -171,7 +162,7 @@ bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
171162
return false;
172163
}
173164

174-
if (isUnavailableOrObsoleted(ExtendedNominal)) {
165+
if (isUnavailableOrObsoletedOnPlatform(ExtendedNominal)) {
175166
return false;
176167
}
177168

0 commit comments

Comments
 (0)