[clang-tools-extra] 61c2276 - [include-cleaner] verbatimSpelling->verbatim, clean up some silly init-lists. NFC

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 11 03:10:20 PST 2022


Author: Sam McCall
Date: 2022-11-11T12:10:12+01:00
New Revision: 61c2276cb231f5cc5698c0bdd2e92d9ecfdefa16

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

LOG: [include-cleaner] verbatimSpelling->verbatim, clean up some silly init-lists. NFC

Added: 
    

Modified: 
    clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
    clang-tools-extra/include-cleaner/lib/Analysis.cpp
    clang-tools-extra/include-cleaner/lib/Record.cpp
    clang-tools-extra/include-cleaner/lib/Types.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
index 87db0cf585a3..78e61b81166a 100644
--- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -107,7 +107,7 @@ struct Header {
     Standard,
     /// A verbatim header spelling, a string quoted with <> or "" that can be
     /// #included directly.
-    VerbatimSpelling,
+    Verbatim,
   };
 
   Header(const FileEntry *FE) : Storage(FE) {}
@@ -121,8 +121,8 @@ struct Header {
   tooling::stdlib::Header standard() const {
     return std::get<Standard>(Storage);
   }
-  StringRef verbatimSpelling() const {
-    return std::get<VerbatimSpelling>(Storage);
+  StringRef verbatim() const {
+    return std::get<Verbatim>(Storage);
   }
 
 private:

diff  --git a/clang-tools-extra/include-cleaner/lib/Analysis.cpp b/clang-tools-extra/include-cleaner/lib/Analysis.cpp
index 4d66c34ce788..b3238e93bcc9 100644
--- a/clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -13,7 +13,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 
 namespace clang::include_cleaner {
@@ -29,11 +28,11 @@ void walkUsed(llvm::ArrayRef<Decl *> ASTRoots,
       if (auto SS = Recognizer(&ND)) {
         // FIXME: Also report forward decls from main-file, so that the caller
         // can decide to insert/ignore a header.
-        return CB({Loc, Symbol(*SS), RT}, findIncludeHeaders({*SS}, SM, PI));
+        return CB({Loc, Symbol(*SS), RT}, findIncludeHeaders(*SS, SM, PI));
       }
       // FIXME: Extract locations from redecls.
       return CB({Loc, Symbol(ND), RT},
-                findIncludeHeaders({ND.getLocation()}, SM, PI));
+                findIncludeHeaders(ND.getLocation(), SM, PI));
     });
   }
   for (const SymbolReference &MacroRef : MacroRefs) {
@@ -61,9 +60,9 @@ llvm::SmallVector<Header> findIncludeHeaders(const SymbolLocation &SLoc,
     // header.
     llvm::StringRef VerbatimSpelling = PI.getPublic(FE);
     if (!VerbatimSpelling.empty())
-      return {{VerbatimSpelling}};
+      return {Header(VerbatimSpelling)};
 
-    Results = {{FE}};
+    Results = {Header(FE)};
     // FIXME: compute transitive exporter headers.
     for (const auto *Export : PI.getExporters(FE, SM.getFileManager()))
       Results.push_back(Export);

diff  --git a/clang-tools-extra/include-cleaner/lib/Record.cpp b/clang-tools-extra/include-cleaner/lib/Record.cpp
index d824e5d06bad..4dabd4aa6d07 100644
--- a/clang-tools-extra/include-cleaner/lib/Record.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -332,8 +332,8 @@ RecordedPP::RecordedIncludes::match(Header H) const {
     for (unsigned I : BySpelling.lookup(H.standard().name().trim("<>")))
       Result.push_back(&All[I]);
     break;
-  case Header::VerbatimSpelling:
-    for (unsigned I : BySpelling.lookup(H.verbatimSpelling().trim("\"<>")))
+  case Header::Verbatim:
+    for (unsigned I : BySpelling.lookup(H.verbatim().trim("\"<>")))
       Result.push_back(&All[I]);
     break;
   }

diff  --git a/clang-tools-extra/include-cleaner/lib/Types.cpp b/clang-tools-extra/include-cleaner/lib/Types.cpp
index 340843e6bdf9..a3b2731401ae 100644
--- a/clang-tools-extra/include-cleaner/lib/Types.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -34,8 +34,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Header &H) {
     return OS << H.physical()->getName();
   case Header::Standard:
     return OS << H.standard().name();
-  case Header::VerbatimSpelling:
-    return OS << H.verbatimSpelling();
+  case Header::Verbatim:
+    return OS << H.verbatim();
   }
   llvm_unreachable("Unhandled Header kind");
 }


        


More information about the cfe-commits mailing list