@@ -2444,27 +2444,27 @@ class AvailabilityWalker : public ASTWalker {
2444
2444
};
2445
2445
2446
2446
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);
2449
2449
maybeDiagStorageAccess (DR->getDecl (), DR->getSourceRange (), DC);
2450
2450
}
2451
2451
if (auto MR = dyn_cast<MemberRefExpr>(E)) {
2452
2452
walkMemberRef (MR);
2453
2453
return skipChildren ();
2454
2454
}
2455
2455
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 ());
2459
2459
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 ());
2463
2463
if (auto DS = dyn_cast<DynamicSubscriptExpr>(E))
2464
- diagAvailability (DS->getMember (), DS->getSourceRange ());
2464
+ diagnoseDeclRefAvailability (DS->getMember (), DS->getSourceRange ());
2465
2465
if (auto S = dyn_cast<SubscriptExpr>(E)) {
2466
2466
if (S->hasDecl ()) {
2467
- diagAvailability (S->getDecl (), S->getSourceRange ());
2467
+ diagnoseDeclRefAvailability (S->getDecl (), S->getSourceRange ());
2468
2468
maybeDiagStorageAccess (S->getDecl ().getDecl (), S->getSourceRange (), DC);
2469
2469
}
2470
2470
}
@@ -2510,9 +2510,13 @@ class AvailabilityWalker : public ASTWalker {
2510
2510
return E;
2511
2511
}
2512
2512
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 ;
2516
2520
2517
2521
private:
2518
2522
bool diagnoseIncDecRemoval (const ValueDecl *D, SourceRange R,
@@ -2577,7 +2581,7 @@ class AvailabilityWalker : public ASTWalker {
2577
2581
2578
2582
ValueDecl *D = E->getMember ().getDecl ();
2579
2583
// Diagnose for the member declaration itself.
2580
- if (diagAvailability (D, E->getNameLoc ().getSourceRange ()))
2584
+ if (diagnoseDeclAvailability (D, E->getNameLoc ().getSourceRange ()))
2581
2585
return ;
2582
2586
2583
2587
// Diagnose for appropriate accessors, given the access context.
@@ -2596,10 +2600,9 @@ class AvailabilityWalker : public ASTWalker {
2596
2600
switch (component.getKind ()) {
2597
2601
case KeyPathExpr::Component::Kind::Property:
2598
2602
case KeyPathExpr::Component::Kind::Subscript: {
2599
- auto * decl = component.getDeclRef (). getDecl ();
2603
+ auto decl = component.getDeclRef ();
2600
2604
auto loc = component.getLoc ();
2601
- SourceRange range (loc, loc);
2602
- diagAvailability (decl, range, nullptr , flags);
2605
+ diagnoseDeclRefAvailability (decl, loc, nullptr , flags);
2603
2606
break ;
2604
2607
}
2605
2608
@@ -2681,7 +2684,7 @@ class AvailabilityWalker : public ASTWalker {
2681
2684
DeclAvailabilityFlags Flags) const {
2682
2685
Flags &= DeclAvailabilityFlag::ForInout;
2683
2686
Flags |= DeclAvailabilityFlag::ContinueOnPotentialUnavailability;
2684
- if (diagAvailability (D, ReferenceRange, /* call*/ nullptr , Flags))
2687
+ if (diagnoseDeclAvailability (D, ReferenceRange, /* call*/ nullptr , Flags))
2685
2688
return ;
2686
2689
}
2687
2690
};
@@ -2690,13 +2693,31 @@ class AvailabilityWalker : public ASTWalker {
2690
2693
// / Diagnose uses of unavailable declarations. Returns true if a diagnostic
2691
2694
// / was emitted.
2692
2695
bool
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 {
2696
2699
if (!declRef)
2697
2700
return false ;
2698
2701
const ValueDecl *D = declRef.getDecl ();
2699
2702
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 {
2700
2721
// Generic parameters are always available.
2701
2722
if (isa<GenericTypeParamDecl>(D))
2702
2723
return false ;
@@ -2726,13 +2747,6 @@ AvailabilityWalker::diagAvailability(ConcreteDeclRef declRef, SourceRange R,
2726
2747
return true ;
2727
2748
}
2728
2749
2729
- if (R.isValid ()) {
2730
- if (diagnoseSubstitutionMapAvailability (R.Start , declRef.getSubstitutions (),
2731
- Where)) {
2732
- return true ;
2733
- }
2734
- }
2735
-
2736
2750
if (diagnoseExplicitUnavailability (D, R, Where, call, Flags))
2737
2751
return true ;
2738
2752
@@ -2923,7 +2937,7 @@ AvailabilityWalker::diagnoseMemoryLayoutMigration(const ValueDecl *D,
2923
2937
}
2924
2938
2925
2939
// / Diagnose uses of unavailable declarations.
2926
- void swift::diagAvailability (const Expr *E, DeclContext *DC) {
2940
+ void swift::diagnoseExprAvailability (const Expr *E, DeclContext *DC) {
2927
2941
auto where = ExportContext::forFunctionBody (DC);
2928
2942
if (where.isImplicit ())
2929
2943
return ;
@@ -2960,7 +2974,7 @@ class StmtAvailabilityWalker : public ASTWalker {
2960
2974
2961
2975
}
2962
2976
2963
- void swift::diagAvailability (const Stmt *S, DeclContext *DC) {
2977
+ void swift::diagnoseStmtAvailability (const Stmt *S, DeclContext *DC) {
2964
2978
// We'll visit the individual statements when we check them.
2965
2979
if (isa<BraceStmt>(S))
2966
2980
return ;
@@ -3186,7 +3200,8 @@ bool swift::diagnoseDeclAvailability(const ValueDecl *Decl,
3186
3200
{
3187
3201
assert (!Where.isImplicit ());
3188
3202
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);
3190
3205
}
3191
3206
3192
3207
// / Should we warn that \p decl needs an explicit availability annotation
0 commit comments