diff options
Diffstat (limited to 'clang-tools-extra/clangd/XRefs.cpp')
-rw-r--r-- | clang-tools-extra/clangd/XRefs.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp index dc69ef76038..1b500c9398b 100644 --- a/clang-tools-extra/clangd/XRefs.cpp +++ b/clang-tools-extra/clangd/XRefs.cpp @@ -254,8 +254,8 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos, } } - SourceLocation SourceLocationBeg = - getBeginningOfIdentifier(AST, Pos, SM.getMainFileID()); + SourceLocation SourceLocationBeg = getBeginningOfIdentifier( + Pos, AST.getSourceManager(), AST.getASTContext().getLangOpts()); // Macros are simple: there's no declaration/definition distinction. // As a consequence, there's no need to look them up in the index either. @@ -408,10 +408,10 @@ std::vector<DocumentHighlight> findDocumentHighlights(ParsedAST &AST, Position Pos) { const SourceManager &SM = AST.getSourceManager(); // FIXME: show references to macro within file? - auto References = - findRefs(getDeclAtPosition( - AST, getBeginningOfIdentifier(AST, Pos, SM.getMainFileID())), - AST); + auto References = findRefs( + getDeclAtPosition(AST, getBeginningOfIdentifier( + Pos, SM, AST.getASTContext().getLangOpts())), + AST); // FIXME: we may get multiple DocumentHighlights with the same location and // different kinds, deduplicate them. @@ -876,7 +876,7 @@ llvm::Optional<HoverInfo> getHover(ParsedAST &AST, Position Pos, const SymbolIndex *Index) { llvm::Optional<HoverInfo> HI; SourceLocation SourceLocationBeg = getBeginningOfIdentifier( - AST, Pos, AST.getSourceManager().getMainFileID()); + Pos, AST.getSourceManager(), AST.getASTContext().getLangOpts()); if (auto M = locateMacroAt(SourceLocationBeg, AST.getPreprocessor())) { HI = getHoverContents(*M, AST); @@ -918,7 +918,8 @@ std::vector<Location> findReferences(ParsedAST &AST, Position Pos, elog("Failed to get a path for the main file, so no references"); return Results; } - auto Loc = getBeginningOfIdentifier(AST, Pos, SM.getMainFileID()); + auto Loc = + getBeginningOfIdentifier(Pos, SM, AST.getASTContext().getLangOpts()); // TODO: should we handle macros, too? auto Decls = getDeclAtPosition(AST, Loc); @@ -974,8 +975,8 @@ std::vector<Location> findReferences(ParsedAST &AST, Position Pos, std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos) { const SourceManager &SM = AST.getSourceManager(); - - auto Loc = getBeginningOfIdentifier(AST, Pos, SM.getMainFileID()); + auto Loc = + getBeginningOfIdentifier(Pos, SM, AST.getASTContext().getLangOpts()); std::vector<SymbolDetails> Results; @@ -1146,7 +1147,7 @@ static void fillSuperTypes(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx, const CXXRecordDecl *findRecordTypeAt(ParsedAST &AST, Position Pos) { SourceLocation SourceLocationBeg = getBeginningOfIdentifier( - AST, Pos, AST.getSourceManager().getMainFileID()); + Pos, AST.getSourceManager(), AST.getASTContext().getLangOpts()); auto Decls = getDeclAtPosition(AST, SourceLocationBeg); if (Decls.empty()) return nullptr; |