summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/XRefs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/XRefs.cpp')
-rw-r--r--clang-tools-extra/clangd/XRefs.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp
index b16e7080aa6..170637b596d 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -131,15 +131,16 @@ SymbolLocation getPreferredLocation(const Location &ASTLoc,
std::vector<const Decl *> getDeclAtPosition(ParsedAST &AST, SourceLocation Pos,
DeclRelationSet Relations) {
- FileID FID;
- unsigned Offset;
- std::tie(FID, Offset) = AST.getSourceManager().getDecomposedSpellingLoc(Pos);
- SelectionTree Selection(AST.getASTContext(), AST.getTokens(), Offset);
+ unsigned Offset = AST.getSourceManager().getDecomposedSpellingLoc(Pos).second;
std::vector<const Decl *> Result;
- if (const SelectionTree::Node *N = Selection.commonAncestor()) {
- auto Decls = targetDecl(N->ASTNode, Relations);
- Result.assign(Decls.begin(), Decls.end());
- }
+ SelectionTree::createEach(AST.getASTContext(), AST.getTokens(), Offset,
+ Offset, [&](SelectionTree ST) {
+ if (const SelectionTree::Node *N =
+ ST.commonAncestor())
+ llvm::copy(targetDecl(N->ASTNode, Relations),
+ std::back_inserter(Result));
+ return !Result.empty();
+ });
return Result;
}
OpenPOWER on IntegriCloud