Skip to content

Commit 19c1765

Browse files
committed
Remove unnecessary work from availability fix-its
As near as I can tell, this was always going to start with DeclarationToSearch and then end up with DeclarationToSearch, since it's already a declaration (and we already checked for null earlier). No test changes observed either.
1 parent 722cb83 commit 19c1765

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,35 +1110,17 @@ static void findAvailabilityFixItNodes(SourceRange ReferenceRange,
11101110
FoundVersionCheckNode =
11111111
findInnermostAncestor(ReferenceRange, SM, SearchRoot, IsGuardable);
11121112

1113-
// Find some Decl that contains the reference range. We use this declaration
1114-
// as a starting place to climb the DeclContext hierarchy to find
1115-
// places to suggest adding @available() annotations.
1116-
InnermostAncestorFinder::MatchPredicate IsDeclaration = [](
1117-
ASTNode Node, ASTWalker::ParentTy Parent) { return Node.is<Decl *>(); };
1118-
1119-
Optional<ASTNode> FoundDeclarationNode =
1120-
findInnermostAncestor(ReferenceRange, SM, SearchRoot, IsDeclaration);
1121-
1122-
const Decl *ContainingDecl = nullptr;
1123-
if (FoundDeclarationNode.hasValue()) {
1124-
ContainingDecl = FoundDeclarationNode.getValue().get<Decl *>();
1125-
}
1126-
1127-
if (!ContainingDecl) {
1128-
ContainingDecl = ReferenceDC->getInnermostMethodContext();
1129-
}
1130-
11311113
// Try to find declarations on which @available attributes can be added.
11321114
// The heuristics for finding these declarations are biased towards deeper
11331115
// nodes in the AST to limit the scope of suggested availability regions
11341116
// and provide a better IDE experience (it can get jumpy if Fix-It locations
11351117
// are far away from the error needing the Fix-It).
1136-
if (ContainingDecl) {
1118+
if (DeclarationToSearch) {
11371119
FoundMemberLevelDecl =
1138-
ancestorMemberLevelDeclForAvailabilityFixit(ContainingDecl);
1120+
ancestorMemberLevelDeclForAvailabilityFixit(DeclarationToSearch);
11391121

11401122
FoundTypeLevelDecl =
1141-
ancestorTypeLevelDeclForAvailabilityFixit(ContainingDecl);
1123+
ancestorTypeLevelDeclForAvailabilityFixit(DeclarationToSearch);
11421124
}
11431125
}
11441126

0 commit comments

Comments
 (0)