[clangd] NFC: Cleanup IncludeCleaner API
authorKirill Bobyrev <kbobyrev@google.com>
Tue, 8 Mar 2022 12:42:50 +0000 (13:42 +0100)
committerKirill Bobyrev <kbobyrev@google.com>
Tue, 8 Mar 2022 12:43:25 +0000 (13:43 +0100)
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
clang-tools-extra/clangd/IncludeCleaner.h

index 90dfb2b..04dbf12 100644 (file)
@@ -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
index ad34e3d..183f84f 100644 (file)
@@ -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);