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 --- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h +++ b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h @@ -52,27 +52,21 @@ Declaration, /// A preprocessor macro, as defined in a specific location. Macro, - /// A recognized symbol from the standard library, like std::string. - Standard, }; Symbol(const Decl &D) : Storage(&D) {} Symbol(struct Macro M) : Storage(M) {} - Symbol(tooling::stdlib::Symbol S) : Storage(S) {} Kind kind() const { return static_cast(Storage.index()); } bool operator==(const Symbol &RHS) const { return Storage == RHS.Storage; } const Decl &declaration() const { return *std::get(Storage); } struct Macro macro() const { return std::get(Storage); } - tooling::stdlib::Symbol standard() const { - return std::get(Storage); - } private: // FIXME: Add support for macros. // Order must match Kind enum! - std::variant Storage; + std::variant Storage; }; llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Symbol &); @@ -122,9 +116,7 @@ tooling::stdlib::Header standard() const { return std::get(Storage); } - StringRef verbatim() const { - return std::get(Storage); - } + StringRef verbatim() const { return std::get(Storage); } private: // Order must match Kind enum! diff --git a/clang-tools-extra/include-cleaner/lib/Analysis.cpp b/clang-tools-extra/include-cleaner/lib/Analysis.cpp --- a/clang-tools-extra/include-cleaner/lib/Analysis.cpp +++ b/clang-tools-extra/include-cleaner/lib/Analysis.cpp @@ -25,13 +25,14 @@ for (auto *Root : ASTRoots) { auto &SM = Root->getASTContext().getSourceManager(); walkAST(*Root, [&](SourceLocation Loc, NamedDecl &ND, RefType RT) { + SymbolReference SymRef{Loc, ND, RT}; 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}, findHeaders(*SS, SM, PI)); + return CB(SymRef, findHeaders(*SS, SM, PI)); } // FIXME: Extract locations from redecls. - return CB({Loc, Symbol(ND), RT}, findHeaders(ND.getLocation(), SM, PI)); + return CB(SymRef, findHeaders(ND.getLocation(), SM, PI)); }); } for (const SymbolReference &MacroRef : MacroRefs) { diff --git a/clang-tools-extra/include-cleaner/lib/Types.cpp b/clang-tools-extra/include-cleaner/lib/Types.cpp --- a/clang-tools-extra/include-cleaner/lib/Types.cpp +++ b/clang-tools-extra/include-cleaner/lib/Types.cpp @@ -22,8 +22,6 @@ return OS << S.declaration().getDeclKindName(); case Symbol::Macro: return OS << S.macro().Name; - case Symbol::Standard: - return OS << S.standard().scope() << S.standard().name(); } llvm_unreachable("Unhandled Symbol kind"); }