Skip to content

Commit 88bc79f

Browse files
committed
AST: Remove unnecessary ASTContext argument.
There's no need to take one as input to a method on `Decl`. NFC.
1 parent 9b7c531 commit 88bc79f

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,8 +1134,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl>, public Swi
11341134
/// Returns the active `@backDeployed` attribute and the `AvailabilityRange`
11351135
/// in which the decl is available as ABI.
11361136
std::optional<std::pair<const BackDeployedAttr *, AvailabilityRange>>
1137-
getBackDeployedAttrAndRange(ASTContext &Ctx,
1138-
bool forTargetVariant = false) const;
1137+
getBackDeployedAttrAndRange(bool forTargetVariant = false) const;
11391138

11401139
/// Returns true if the decl has a valid and active `@backDeployed` attribute.
11411140
bool isBackDeployed() const;

lib/AST/Decl.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,13 @@ Decl::getIntroducedOSVersion(PlatformKind Kind) const {
597597
}
598598

599599
std::optional<std::pair<const BackDeployedAttr *, AvailabilityRange>>
600-
Decl::getBackDeployedAttrAndRange(ASTContext &Ctx,
601-
bool forTargetVariant) const {
602-
if (auto *attr = getAttrs().getBackDeployed(Ctx, forTargetVariant)) {
600+
Decl::getBackDeployedAttrAndRange(bool forTargetVariant) const {
601+
auto &ctx = getASTContext();
602+
if (auto *attr = getAttrs().getBackDeployed(ctx, forTargetVariant)) {
603603
auto version = attr->getVersion();
604604
AvailabilityDomain ignoredDomain;
605605
AvailabilityInference::updateBeforeAvailabilityDomainForFallback(
606-
attr, getASTContext(), ignoredDomain, version);
606+
attr, ctx, ignoredDomain, version);
607607

608608
// If the remap for fallback resulted in 1.0, then the
609609
// backdeployment prior to that is not meaningful.
@@ -615,14 +615,12 @@ Decl::getBackDeployedAttrAndRange(ASTContext &Ctx,
615615

616616
// Accessors may inherit `@backDeployed`.
617617
if (auto *AD = dyn_cast<AccessorDecl>(this))
618-
return AD->getStorage()->getBackDeployedAttrAndRange(Ctx, forTargetVariant);
618+
return AD->getStorage()->getBackDeployedAttrAndRange(forTargetVariant);
619619

620620
return std::nullopt;
621621
}
622622

623623
bool Decl::isBackDeployed() const {
624-
auto &Ctx = getASTContext();
625-
626624
// A function declared in a local context can never be back-deployed.
627625
if (getDeclContext()->isLocalContext())
628626
return false;
@@ -636,11 +634,11 @@ bool Decl::isBackDeployed() const {
636634
return false;
637635
}
638636

639-
if (getBackDeployedAttrAndRange(Ctx))
637+
if (getBackDeployedAttrAndRange())
640638
return true;
641639

642-
if (Ctx.LangOpts.TargetVariant) {
643-
if (getBackDeployedAttrAndRange(Ctx, /*forTargetVariant=*/true))
640+
if (getASTContext().LangOpts.TargetVariant) {
641+
if (getBackDeployedAttrAndRange(/*forTargetVariant=*/true))
644642
return true;
645643
}
646644

@@ -1482,7 +1480,7 @@ AvailabilityRange Decl::getAvailabilityForLinkage() const {
14821480

14831481
// When computing availability for linkage, use the "before" version from
14841482
// the @backDeployed attribute, if present.
1485-
if (auto backDeployedAttrAndRange = getBackDeployedAttrAndRange(ctx))
1483+
if (auto backDeployedAttrAndRange = getBackDeployedAttrAndRange())
14861484
return backDeployedAttrAndRange->second;
14871485

14881486
auto containingContext = AvailabilityInference::annotatedAvailableRange(this);

lib/SILGen/SILGenAvailability.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ static std::optional<AvailabilityQuery>
113113
getAvailabilityQueryForBackDeployment(AbstractFunctionDecl *AFD) {
114114
auto &ctx = AFD->getASTContext();
115115
if (ctx.LangOpts.TargetVariant) {
116-
auto primaryAttrAndRange = AFD->getBackDeployedAttrAndRange(ctx);
116+
auto primaryAttrAndRange = AFD->getBackDeployedAttrAndRange();
117117
auto variantAttrAndRange =
118-
AFD->getBackDeployedAttrAndRange(ctx, /*forTargetVariant=*/true);
118+
AFD->getBackDeployedAttrAndRange(/*forTargetVariant=*/true);
119119

120120
if (!primaryAttrAndRange && !variantAttrAndRange)
121121
return std::nullopt;
@@ -134,7 +134,7 @@ getAvailabilityQueryForBackDeployment(AbstractFunctionDecl *AFD) {
134134
primaryRange, variantRange);
135135
}
136136

137-
if (auto primaryAttrAndRange = AFD->getBackDeployedAttrAndRange(ctx))
137+
if (auto primaryAttrAndRange = AFD->getBackDeployedAttrAndRange())
138138
return AvailabilityQuery::dynamic(
139139
primaryAttrAndRange->first->getAvailabilityDomain(),
140140
primaryAttrAndRange->second, std::nullopt);
@@ -284,7 +284,7 @@ SILGenFunction::emitIfAvailableQuery(SILLocation loc,
284284
bool SILGenModule::requiresBackDeploymentThunk(ValueDecl *decl,
285285
ResilienceExpansion expansion) {
286286
auto &ctx = getASTContext();
287-
auto attrAndRange = decl->getBackDeployedAttrAndRange(ctx);
287+
auto attrAndRange = decl->getBackDeployedAttrAndRange();
288288
if (!attrAndRange)
289289
return false;
290290

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5266,7 +5266,7 @@ void AttributeChecker::checkBackDeployedAttrs(
52665266
std::map<PlatformKind, SourceLoc> seenPlatforms;
52675267

52685268
const BackDeployedAttr *ActiveAttr = nullptr;
5269-
if (auto AttrAndRange = D->getBackDeployedAttrAndRange(Ctx))
5269+
if (auto AttrAndRange = D->getBackDeployedAttrAndRange())
52705270
ActiveAttr = AttrAndRange->first;
52715271

52725272
for (auto *Attr : Attrs) {

0 commit comments

Comments
 (0)