From d5106c8f973b76e49d64ac3d91236efafd771c7c Mon Sep 17 00:00:00 2001 From: Kirill Bobyrev Date: Tue, 8 Mar 2022 13:42:50 +0100 Subject: [PATCH] [clangd] NFC: Cleanup IncludeCleaner API Make a further improvement to decrease verbosity of the API: ASTContext provides SourceManager access. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D119842 --- clang-tools-extra/clangd/IncludeCleaner.cpp | 8 ++++---- clang-tools-extra/clangd/IncludeCleaner.h | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/clangd/IncludeCleaner.cpp b/clang-tools-extra/clangd/IncludeCleaner.cpp index 90dfb2b..04dbf12 100644 --- a/clang-tools-extra/clangd/IncludeCleaner.cpp +++ b/clang-tools-extra/clangd/IncludeCleaner.cpp @@ -286,11 +286,11 @@ FileID headerResponsible(FileID ID, const SourceManager &SM, } // namespace -ReferencedLocations findReferencedLocations(const SourceManager &SM, - ASTContext &Ctx, Preprocessor &PP, +ReferencedLocations findReferencedLocations(ASTContext &Ctx, Preprocessor &PP, const syntax::TokenBuffer *Tokens) { trace::Span Tracer("IncludeCleaner::findReferencedLocations"); ReferencedLocations Result; + const auto &SM = Ctx.getSourceManager(); ReferencedLocationCrawler Crawler(Result, SM); Crawler.TraverseAST(Ctx); if (Tokens) @@ -299,8 +299,8 @@ ReferencedLocations findReferencedLocations(const SourceManager &SM, } ReferencedLocations findReferencedLocations(ParsedAST &AST) { - return findReferencedLocations(AST.getSourceManager(), AST.getASTContext(), - AST.getPreprocessor(), &AST.getTokens()); + return findReferencedLocations(AST.getASTContext(), AST.getPreprocessor(), + &AST.getTokens()); } ReferencedFiles diff --git a/clang-tools-extra/clangd/IncludeCleaner.h b/clang-tools-extra/clangd/IncludeCleaner.h index ad34e3d..183f84f 100644 --- a/clang-tools-extra/clangd/IncludeCleaner.h +++ b/clang-tools-extra/clangd/IncludeCleaner.h @@ -51,8 +51,7 @@ struct ReferencedLocations { /// - don't attempt to describe where symbols were referenced from in /// ambiguous cases (e.g. implicitly used symbols, multiple declarations) /// - err on the side of reporting all possible locations -ReferencedLocations findReferencedLocations(const SourceManager &SM, - ASTContext &Ctx, Preprocessor &PP, +ReferencedLocations findReferencedLocations(ASTContext &Ctx, Preprocessor &PP, const syntax::TokenBuffer *Tokens); ReferencedLocations findReferencedLocations(ParsedAST &AST); -- 2.7.4