From 61c2276cb231f5cc5698c0bdd2e92d9ecfdefa16 Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Fri, 11 Nov 2022 12:10:01 +0100 Subject: [PATCH] [include-cleaner] verbatimSpelling->verbatim, clean up some silly init-lists. NFC --- .../include/clang-include-cleaner/Types.h | 6 +++--- clang-tools-extra/include-cleaner/lib/Analysis.cpp | 9 ++++----- clang-tools-extra/include-cleaner/lib/Record.cpp | 4 ++-- clang-tools-extra/include-cleaner/lib/Types.cpp | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) 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(Storage); } - StringRef verbatimSpelling() const { - return std::get(Storage); + StringRef verbatim() const { + return std::get(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 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
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"); } -- 2.34.1