@@ -2444,27 +2444,27 @@ class AvailabilityWalker : public ASTWalker {
24442444 };
24452445
24462446 if (auto DR = dyn_cast<DeclRefExpr>(E)) {
2447- diagAvailability (DR->getDeclRef (), DR->getSourceRange (),
2448- getEnclosingApplyExpr (), None);
2447+ diagnoseDeclRefAvailability (DR->getDeclRef (), DR->getSourceRange (),
2448+ getEnclosingApplyExpr (), None);
24492449 maybeDiagStorageAccess (DR->getDecl (), DR->getSourceRange (), DC);
24502450 }
24512451 if (auto MR = dyn_cast<MemberRefExpr>(E)) {
24522452 walkMemberRef (MR);
24532453 return skipChildren ();
24542454 }
24552455 if (auto OCDR = dyn_cast<OtherConstructorDeclRefExpr>(E))
2456- diagAvailability (OCDR->getDeclRef (),
2457- OCDR->getConstructorLoc ().getSourceRange (),
2458- getEnclosingApplyExpr ());
2456+ diagnoseDeclRefAvailability (OCDR->getDeclRef (),
2457+ OCDR->getConstructorLoc ().getSourceRange (),
2458+ getEnclosingApplyExpr ());
24592459 if (auto DMR = dyn_cast<DynamicMemberRefExpr>(E))
2460- diagAvailability (DMR->getMember (),
2461- DMR->getNameLoc ().getSourceRange (),
2462- getEnclosingApplyExpr ());
2460+ diagnoseDeclRefAvailability (DMR->getMember (),
2461+ DMR->getNameLoc ().getSourceRange (),
2462+ getEnclosingApplyExpr ());
24632463 if (auto DS = dyn_cast<DynamicSubscriptExpr>(E))
2464- diagAvailability (DS->getMember (), DS->getSourceRange ());
2464+ diagnoseDeclRefAvailability (DS->getMember (), DS->getSourceRange ());
24652465 if (auto S = dyn_cast<SubscriptExpr>(E)) {
24662466 if (S->hasDecl ()) {
2467- diagAvailability (S->getDecl (), S->getSourceRange ());
2467+ diagnoseDeclRefAvailability (S->getDecl (), S->getSourceRange ());
24682468 maybeDiagStorageAccess (S->getDecl ().getDecl (), S->getSourceRange (), DC);
24692469 }
24702470 }
@@ -2510,9 +2510,13 @@ class AvailabilityWalker : public ASTWalker {
25102510 return E;
25112511 }
25122512
2513- bool diagAvailability (ConcreteDeclRef declRef, SourceRange R,
2514- const ApplyExpr *call = nullptr ,
2515- DeclAvailabilityFlags flags = None) const ;
2513+ bool diagnoseDeclRefAvailability (ConcreteDeclRef declRef, SourceRange R,
2514+ const ApplyExpr *call = nullptr ,
2515+ DeclAvailabilityFlags flags = None) const ;
2516+
2517+ bool diagnoseDeclAvailability (const ValueDecl *D, SourceRange R,
2518+ const ApplyExpr *call = nullptr ,
2519+ DeclAvailabilityFlags flags = None) const ;
25162520
25172521private:
25182522 bool diagnoseIncDecRemoval (const ValueDecl *D, SourceRange R,
@@ -2577,7 +2581,7 @@ class AvailabilityWalker : public ASTWalker {
25772581
25782582 ValueDecl *D = E->getMember ().getDecl ();
25792583 // Diagnose for the member declaration itself.
2580- if (diagAvailability (D, E->getNameLoc ().getSourceRange ()))
2584+ if (diagnoseDeclAvailability (D, E->getNameLoc ().getSourceRange ()))
25812585 return ;
25822586
25832587 // Diagnose for appropriate accessors, given the access context.
@@ -2596,10 +2600,9 @@ class AvailabilityWalker : public ASTWalker {
25962600 switch (component.getKind ()) {
25972601 case KeyPathExpr::Component::Kind::Property:
25982602 case KeyPathExpr::Component::Kind::Subscript: {
2599- auto * decl = component.getDeclRef (). getDecl ();
2603+ auto decl = component.getDeclRef ();
26002604 auto loc = component.getLoc ();
2601- SourceRange range (loc, loc);
2602- diagAvailability (decl, range, nullptr , flags);
2605+ diagnoseDeclRefAvailability (decl, loc, nullptr , flags);
26032606 break ;
26042607 }
26052608
@@ -2681,7 +2684,7 @@ class AvailabilityWalker : public ASTWalker {
26812684 DeclAvailabilityFlags Flags) const {
26822685 Flags &= DeclAvailabilityFlag::ForInout;
26832686 Flags |= DeclAvailabilityFlag::ContinueOnPotentialUnavailability;
2684- if (diagAvailability (D, ReferenceRange, /* call*/ nullptr , Flags))
2687+ if (diagnoseDeclAvailability (D, ReferenceRange, /* call*/ nullptr , Flags))
26852688 return ;
26862689 }
26872690};
@@ -2690,13 +2693,31 @@ class AvailabilityWalker : public ASTWalker {
26902693// / Diagnose uses of unavailable declarations. Returns true if a diagnostic
26912694// / was emitted.
26922695bool
2693- AvailabilityWalker::diagAvailability (ConcreteDeclRef declRef, SourceRange R,
2694- const ApplyExpr *call,
2695- DeclAvailabilityFlags Flags) const {
2696+ AvailabilityWalker::diagnoseDeclRefAvailability (
2697+ ConcreteDeclRef declRef, SourceRange R, const ApplyExpr *call,
2698+ DeclAvailabilityFlags Flags) const {
26962699 if (!declRef)
26972700 return false ;
26982701 const ValueDecl *D = declRef.getDecl ();
26992702
2703+ diagnoseDeclAvailability (D, R, call, Flags);
2704+
2705+ if (R.isValid ()) {
2706+ if (diagnoseSubstitutionMapAvailability (R.Start , declRef.getSubstitutions (),
2707+ Where)) {
2708+ return true ;
2709+ }
2710+ }
2711+
2712+ return false ;
2713+ }
2714+
2715+ // / Diagnose uses of unavailable declarations. Returns true if a diagnostic
2716+ // / was emitted.
2717+ bool
2718+ AvailabilityWalker::diagnoseDeclAvailability (
2719+ const ValueDecl *D, SourceRange R, const ApplyExpr *call,
2720+ DeclAvailabilityFlags Flags) const {
27002721 // Generic parameters are always available.
27012722 if (isa<GenericTypeParamDecl>(D))
27022723 return false ;
@@ -2726,13 +2747,6 @@ AvailabilityWalker::diagAvailability(ConcreteDeclRef declRef, SourceRange R,
27262747 return true ;
27272748 }
27282749
2729- if (R.isValid ()) {
2730- if (diagnoseSubstitutionMapAvailability (R.Start , declRef.getSubstitutions (),
2731- Where)) {
2732- return true ;
2733- }
2734- }
2735-
27362750 if (diagnoseExplicitUnavailability (D, R, Where, call, Flags))
27372751 return true ;
27382752
@@ -2923,7 +2937,7 @@ AvailabilityWalker::diagnoseMemoryLayoutMigration(const ValueDecl *D,
29232937}
29242938
29252939// / Diagnose uses of unavailable declarations.
2926- void swift::diagAvailability (const Expr *E, DeclContext *DC) {
2940+ void swift::diagnoseExprAvailability (const Expr *E, DeclContext *DC) {
29272941 auto where = ExportContext::forFunctionBody (DC);
29282942 if (where.isImplicit ())
29292943 return ;
@@ -2960,7 +2974,7 @@ class StmtAvailabilityWalker : public ASTWalker {
29602974
29612975}
29622976
2963- void swift::diagAvailability (const Stmt *S, DeclContext *DC) {
2977+ void swift::diagnoseStmtAvailability (const Stmt *S, DeclContext *DC) {
29642978 // We'll visit the individual statements when we check them.
29652979 if (isa<BraceStmt>(S))
29662980 return ;
@@ -3186,7 +3200,8 @@ bool swift::diagnoseDeclAvailability(const ValueDecl *Decl,
31863200{
31873201 assert (!Where.isImplicit ());
31883202 AvailabilityWalker AW (Where);
3189- return AW.diagAvailability (const_cast <ValueDecl *>(Decl), R, nullptr , Flags);
3203+ return AW.diagnoseDeclAvailability (const_cast <ValueDecl *>(Decl), R,
3204+ nullptr , Flags);
31903205}
31913206
31923207// / Should we warn that \p decl needs an explicit availability annotation
0 commit comments