@@ -1404,10 +1404,7 @@ const AvailableAttr *TypeChecker::getDeprecated(const Decl *D) {
1404
1404
static bool
1405
1405
someEnclosingDeclMatches (SourceRange ReferenceRange,
1406
1406
const DeclContext *ReferenceDC,
1407
- TypeChecker &TC,
1408
1407
llvm::function_ref<bool (const Decl *)> Pred) {
1409
- ASTContext &Ctx = TC.Context ;
1410
-
1411
1408
// Climb the DeclContext hierarchy to see if any of the containing
1412
1409
// declarations matches the predicate.
1413
1410
const DeclContext *DC = ReferenceDC;
@@ -1446,6 +1443,7 @@ someEnclosingDeclMatches(SourceRange ReferenceRange,
1446
1443
if (ReferenceRange.isInvalid ())
1447
1444
return false ;
1448
1445
1446
+ ASTContext &Ctx = ReferenceDC->getASTContext ();
1449
1447
const Decl *DeclToSearch =
1450
1448
findContainingDeclaration (ReferenceRange, ReferenceDC, Ctx.SourceMgr );
1451
1449
@@ -1474,28 +1472,32 @@ someEnclosingDeclMatches(SourceRange ReferenceRange,
1474
1472
return false ;
1475
1473
}
1476
1474
1477
- bool TypeChecker::isInsideImplicitFunction (SourceRange ReferenceRange,
1478
- const DeclContext *DC) {
1475
+ // / Returns true if the reference or any of its parents is an
1476
+ // / implicit function.
1477
+ static bool isInsideImplicitFunction (SourceRange ReferenceRange,
1478
+ const DeclContext *DC) {
1479
1479
auto IsInsideImplicitFunc = [](const Decl *D) {
1480
1480
auto *AFD = dyn_cast<AbstractFunctionDecl>(D);
1481
1481
return AFD && AFD->isImplicit ();
1482
1482
};
1483
1483
1484
- return someEnclosingDeclMatches (ReferenceRange, DC, *this ,
1485
- IsInsideImplicitFunc);
1484
+ return someEnclosingDeclMatches (ReferenceRange, DC, IsInsideImplicitFunc);
1486
1485
}
1487
1486
1488
- bool TypeChecker::isInsideUnavailableDeclaration (
1489
- SourceRange ReferenceRange, const DeclContext *ReferenceDC) {
1487
+ // / Returns true if the reference or any of its parents is an
1488
+ // / unavailable (or obsoleted) declaration.
1489
+ static bool isInsideUnavailableDeclaration (SourceRange ReferenceRange,
1490
+ const DeclContext *ReferenceDC) {
1490
1491
auto IsUnavailable = [](const Decl *D) {
1491
1492
return D->getAttrs ().getUnavailable (D->getASTContext ());
1492
1493
};
1493
1494
1494
- return someEnclosingDeclMatches (ReferenceRange, ReferenceDC, *this ,
1495
- IsUnavailable);
1495
+ return someEnclosingDeclMatches (ReferenceRange, ReferenceDC, IsUnavailable);
1496
1496
}
1497
1497
1498
- bool TypeChecker::isInsideCompatibleUnavailableDeclaration (
1498
+ // / Returns true if the reference or any of its parents is an
1499
+ // / unconditional unavailable declaration for the same platform.
1500
+ static bool isInsideCompatibleUnavailableDeclaration (
1499
1501
SourceRange ReferenceRange, const DeclContext *ReferenceDC,
1500
1502
const AvailableAttr *attr) {
1501
1503
if (!attr->isUnconditionallyUnavailable ()) {
@@ -1512,18 +1514,18 @@ bool TypeChecker::isInsideCompatibleUnavailableDeclaration(
1512
1514
return EnclosingUnavailable && EnclosingUnavailable->Platform == platform;
1513
1515
};
1514
1516
1515
- return someEnclosingDeclMatches (ReferenceRange, ReferenceDC, *this ,
1516
- IsUnavailable);
1517
+ return someEnclosingDeclMatches (ReferenceRange, ReferenceDC, IsUnavailable);
1517
1518
}
1518
1519
1519
- bool TypeChecker::isInsideDeprecatedDeclaration (SourceRange ReferenceRange,
1520
- const DeclContext *ReferenceDC){
1520
+ // / Returns true if the reference is lexically contained in a declaration
1521
+ // / that is deprecated on all deployment targets.
1522
+ static bool isInsideDeprecatedDeclaration (SourceRange ReferenceRange,
1523
+ const DeclContext *ReferenceDC){
1521
1524
auto IsDeprecated = [](const Decl *D) {
1522
1525
return D->getAttrs ().getDeprecated (D->getASTContext ());
1523
1526
};
1524
1527
1525
- return someEnclosingDeclMatches (ReferenceRange, ReferenceDC, *this ,
1526
- IsDeprecated);
1528
+ return someEnclosingDeclMatches (ReferenceRange, ReferenceDC, IsDeprecated);
1527
1529
}
1528
1530
1529
1531
static void fixItAvailableAttrRename (TypeChecker &TC,
0 commit comments