[clang-tools-extra] c333b92 - [include-cleaner] Missing changes from 38cccb906603

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 8 11:18:21 PST 2022


Author: Sam McCall
Date: 2022-11-08T20:18:10+01:00
New Revision: c333b92b72b40d1f39d89ab94f764baeb8bb0cab

URL: https://github.com/llvm/llvm-project/commit/c333b92b72b40d1f39d89ab94f764baeb8bb0cab
DIFF: https://github.com/llvm/llvm-project/commit/c333b92b72b40d1f39d89ab94f764baeb8bb0cab.diff

LOG: [include-cleaner] Missing changes from 38cccb906603

Added: 
    

Modified: 
    clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
    clang-tools-extra/include-cleaner/lib/Analysis.cpp
    clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
index 4c5c90e769ae..62277199871b 100644
--- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
+++ b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
@@ -28,7 +28,7 @@ namespace include_cleaner {
 /// that symbol may be provided by several headers.
 /// FIXME: Provide signals about the providing headers so the caller can filter
 /// and rank the results.
-using UsedSymbolCB = llvm::function_ref<void(SymbolReference SymRef,
+using UsedSymbolCB = llvm::function_ref<void(const SymbolReference &SymRef,
                                              llvm::ArrayRef<Header> Providers)>;
 
 /// Find and report all references to symbols in a region of code.
@@ -44,8 +44,9 @@ using UsedSymbolCB = llvm::function_ref<void(SymbolReference SymRef,
 ///    the headers for any referenced symbol
 /// FIXME: Take in an include structure to improve location to header mappings
 /// (e.g. IWYU pragmas).
-void walkUsed(const SourceManager &, llvm::ArrayRef<Decl *> ASTRoots,
-              llvm::ArrayRef<SymbolReference> MacroRefs, UsedSymbolCB CB);
+void walkUsed(llvm::ArrayRef<Decl *> ASTRoots,
+              llvm::ArrayRef<SymbolReference> MacroRefs, const SourceManager &,
+              UsedSymbolCB CB);
 
 } // namespace include_cleaner
 } // namespace clang

diff  --git a/clang-tools-extra/include-cleaner/lib/Analysis.cpp b/clang-tools-extra/include-cleaner/lib/Analysis.cpp
index b4dfd129c60d..f7c8bdeee0bf 100644
--- a/clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -28,8 +28,9 @@ toHeader(llvm::ArrayRef<tooling::stdlib::Header> Headers) {
 }
 } // namespace
 
-void walkUsed(const SourceManager &SM, llvm::ArrayRef<Decl *> ASTRoots,
-              llvm::ArrayRef<SymbolReference> MacroRefs, UsedSymbolCB CB) {
+void walkUsed(llvm::ArrayRef<Decl *> ASTRoots,
+              llvm::ArrayRef<SymbolReference> MacroRefs,
+              const SourceManager &SM, UsedSymbolCB CB) {
   tooling::stdlib::Recognizer Recognizer;
   for (auto *Root : ASTRoots) {
     auto &SM = Root->getASTContext().getSourceManager();

diff  --git a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
index bd794037e85a..49652ad35023 100644
--- a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -50,9 +50,9 @@ TEST(WalkUsed, Basic) {
 
   auto &SM = AST.sourceManager();
   llvm::DenseMap<size_t, std::vector<Header>> OffsetToProviders;
-  walkUsed(SM, TopLevelDecls, /*MacroRefs=*/{},
-           [&](SymbolReference SymRef, llvm::ArrayRef<Header> Providers) {
-             auto [FID, Offset] = SM.getDecomposedLoc(SymRef.RefLocation);
+  walkUsed(TopLevelDecls, /*MacroRefs=*/{}, SM,
+           [&](const SymbolReference &Ref, llvm::ArrayRef<Header> Providers) {
+             auto [FID, Offset] = SM.getDecomposedLoc(Ref.RefLocation);
              EXPECT_EQ(FID, SM.getMainFileID());
              OffsetToProviders.try_emplace(Offset, Providers.vec());
            });
@@ -89,11 +89,12 @@ TEST(WalkUsed, MacroRefs) {
   Symbol Answer =
       Macro{&Idents.get("ANSWER"), SM.getComposedLoc(HdrID, Hdr.point())};
   llvm::DenseMap<size_t, std::vector<Header>> OffsetToProviders;
-  walkUsed(SM, /*ASTRoots=*/{}, /*MacroRefs=*/
+  walkUsed(/*ASTRoots=*/{}, /*MacroRefs=*/
            {SymbolReference{SM.getComposedLoc(SM.getMainFileID(), Main.point()),
                             Answer, RefType::Explicit}},
-           [&](SymbolReference SymRef, llvm::ArrayRef<Header> Providers) {
-             auto [FID, Offset] = SM.getDecomposedLoc(SymRef.RefLocation);
+           SM,
+           [&](const SymbolReference &Ref, llvm::ArrayRef<Header> Providers) {
+             auto [FID, Offset] = SM.getDecomposedLoc(Ref.RefLocation);
              EXPECT_EQ(FID, SM.getMainFileID());
              OffsetToProviders.try_emplace(Offset, Providers.vec());
            });


        


More information about the cfe-commits mailing list