Skip to content

Commit c2e8e30

Browse files
committed
AST: Remove AvailableAttr::isActivePlatform().
1 parent b4e2cff commit c2e8e30

File tree

4 files changed

+10
-25
lines changed

4 files changed

+10
-25
lines changed

include/swift/AST/Attr.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,6 @@ class AvailableAttr : public DeclAttribute {
827827
return swift::prettyPlatformString(getPlatform());
828828
}
829829

830-
/// Returns true if this attribute is active given the current platform.
831-
bool isActivePlatform(const ASTContext &ctx) const;
832-
833830
/// Create an AvailableAttr that indicates specific availability
834831
/// for all platforms.
835832
static AvailableAttr *

lib/AST/Attr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,10 +2148,6 @@ AvailableAttr::createPlatformAgnostic(ASTContext &C,
21482148
/*SPI=*/false);
21492149
}
21502150

2151-
bool AvailableAttr::isActivePlatform(const ASTContext &ctx) const {
2152-
return isPlatformActive(getPlatform(), ctx.LangOpts);
2153-
}
2154-
21552151
bool BackDeployedAttr::isActivePlatform(const ASTContext &ctx,
21562152
bool forTargetVariant) const {
21572153
return isPlatformActive(Platform, ctx.LangOpts, forTargetVariant);

lib/AST/Availability.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ bool AvailabilityInference::isAvailableAsSPI(const Decl *D) {
829829
AvailabilityRange
830830
SemanticAvailableAttr::getIntroducedRange(ASTContext &Ctx) const {
831831
auto *attr = getParsedAttr();
832-
assert(attr->isActivePlatform(Ctx));
832+
assert(domain.isActive(Ctx));
833833

834834
llvm::VersionTuple IntroducedVersion = attr->Introduced.value();
835835
StringRef Platform = attr->prettyPlatformString();

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -317,25 +317,17 @@ ExportContext::getExportabilityReason() const {
317317
return std::nullopt;
318318
}
319319

320-
/// Returns the first availability attribute on the declaration that is active
321-
/// on the target platform.
322-
static const AvailableAttr *getActiveAvailableAttribute(const Decl *D,
323-
ASTContext &AC) {
320+
/// Returns true if there is any availability attribute on the declaration
321+
/// that is active.
322+
static bool hasActiveAvailableAttribute(const Decl *D, ASTContext &ctx) {
324323
D = abstractSyntaxDeclForAvailableAttribute(D);
325324

326-
for (auto Attr : D->getAttrs())
327-
if (auto AvAttr = dyn_cast<AvailableAttr>(Attr)) {
328-
if (!AvAttr->isInvalid() && AvAttr->isActivePlatform(AC)) {
329-
return AvAttr;
330-
}
331-
}
332-
return nullptr;
333-
}
325+
for (auto Attr : D->getSemanticAvailableAttrs()) {
326+
if (Attr.isActive(ctx))
327+
return true;
328+
}
334329

335-
/// Returns true if there is any availability attribute on the declaration
336-
/// that is active on the target platform.
337-
static bool hasActiveAvailableAttribute(const Decl *D, ASTContext &AC) {
338-
return getActiveAvailableAttribute(D, AC);
330+
return false;
339331
}
340332

341333
static bool computeContainedByDeploymentTarget(AvailabilityScope *scope,
@@ -1979,7 +1971,7 @@ fixAvailabilityForDecl(SourceRange ReferenceRange, const Decl *D,
19791971
if (TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable(D).has_value())
19801972
return;
19811973

1982-
if (getActiveAvailableAttribute(D, Context)) {
1974+
if (hasActiveAvailableAttribute(D, Context)) {
19831975
// For QoI, in future should emit a fixit to update the existing attribute.
19841976
return;
19851977
}

0 commit comments

Comments
 (0)