From b46cf502051a5b441d1c14817ad4303f389a3aca Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Thu, 19 Dec 2013 21:08:23 +0000 Subject: [PATCH] [cleanup] Random assortment of simple cleanups. Pruning header includes and forward references and fixing comments. llvm-svn: 197720 --- lld/include/lld/Core/Atom.h | 8 ------- lld/include/lld/Core/DefinedAtom.h | 9 ++------ lld/include/lld/Core/File.h | 1 - lld/include/lld/Core/InputGraph.h | 11 +++++----- lld/include/lld/Core/LinkingContext.h | 22 +++++++------------ lld/include/lld/Core/Reference.h | 3 ++- lld/include/lld/Core/SharedLibraryAtom.h | 4 ---- lld/include/lld/Core/SharedLibraryFile.h | 1 - lld/include/lld/Core/SymbolTable.h | 1 - lld/include/lld/Core/UndefinedAtom.h | 2 +- lld/include/lld/Driver/GnuLdInputGraph.h | 2 +- lld/include/lld/Passes/LayoutPass.h | 5 ----- lld/include/lld/Passes/RoundTripNativePass.h | 1 - lld/include/lld/Passes/RoundTripYAMLPass.h | 1 - lld/include/lld/ReaderWriter/AtomLayout.h | 2 -- lld/include/lld/ReaderWriter/FileArchive.h | 2 +- .../lld/ReaderWriter/MachOLinkingContext.h | 2 -- .../lld/ReaderWriter/PECOFFLinkingContext.h | 8 +++---- lld/include/lld/ReaderWriter/Writer.h | 4 ++-- 19 files changed, 26 insertions(+), 63 deletions(-) diff --git a/lld/include/lld/Core/Atom.h b/lld/include/lld/Core/Atom.h index dd23d7ca4afc..10763c52aed4 100644 --- a/lld/include/lld/Core/Atom.h +++ b/lld/include/lld/Core/Atom.h @@ -12,14 +12,6 @@ #include "lld/Core/LLVM.h" -#include "llvm/Support/DataTypes.h" - -#include - -namespace llvm { - class StringRef; -} - namespace lld { class File; diff --git a/lld/include/lld/Core/DefinedAtom.h b/lld/include/lld/Core/DefinedAtom.h index e12033a28f2b..b3e05a56b039 100644 --- a/lld/include/lld/Core/DefinedAtom.h +++ b/lld/include/lld/Core/DefinedAtom.h @@ -11,16 +11,11 @@ #define LLD_CORE_DEFINED_ATOM_H #include "lld/Core/Atom.h" -#include "lld/Core/Reference.h" - -namespace llvm { - template - class ArrayRef; - class StringRef; -} +#include "lld/Core/LLVM.h" namespace lld { class File; +class Reference; /// \brief The fundamental unit of linking. /// diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h index 3a48c4320ebf..899245d2773f 100644 --- a/lld/include/lld/Core/File.h +++ b/lld/include/lld/Core/File.h @@ -17,7 +17,6 @@ #include "lld/Core/LinkingContext.h" #include "lld/Core/UndefinedAtom.h" -#include "llvm/ADT/StringRef.h" #include "llvm/Support/ErrorHandling.h" #include diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h index b45006ad1f94..8d4413c0dd97 100644 --- a/lld/include/lld/Core/InputGraph.h +++ b/lld/include/lld/Core/InputGraph.h @@ -17,7 +17,6 @@ #define LLD_CORE_INPUT_GRAPH_H #include "lld/Core/File.h" -#include "llvm/ADT/StringRef.h" #include "llvm/Option/ArgList.h" #include "llvm/Support/ErrorOr.h" @@ -75,8 +74,8 @@ public: /// \brief Do postprocessing of the InputGraph if there is a need for the /// to provide additional information to the user, also rearranges - /// InputElements by their ordinals. If an user wants to place an input file - /// at the desired position, the user can do that + /// InputElements by their ordinals. If a user wants to place an input file + /// at the desired position, the user can do that. virtual void doPostProcess(); range inputElements() { @@ -210,7 +209,7 @@ class ControlNode : public InputElement { public: /// A control node could be of several types supported by InputGraph /// Future kinds of Control node could be added - enum class ControlKind : uint8_t{ + enum class ControlKind : uint8_t { Simple, // Represents a simple control node Group // Represents a type associated with ControlNodes }; @@ -225,7 +224,7 @@ public: virtual ~ControlNode() {} /// \brief Return the kind of control node - virtual ControlNode::ControlKind controlKind() { return _controlKind; } + virtual ControlKind controlKind() { return _controlKind; } /// \brief Process control start/exit virtual bool processControlEnter() { return true; } @@ -298,7 +297,7 @@ public: return make_range(_files.begin(), _files.end()); } - /// \brief number of files. + /// \brief number of files. size_t numFiles() const { return _files.size(); } /// \brief add a file to the list of files diff --git a/lld/include/lld/Core/LinkingContext.h b/lld/include/lld/Core/LinkingContext.h index b4e53dce3352..2373a8b83b3a 100644 --- a/lld/include/lld/Core/LinkingContext.h +++ b/lld/include/lld/Core/LinkingContext.h @@ -24,10 +24,6 @@ #include #include -namespace llvm { -class Triple; -} - namespace lld { class PassManager; class File; @@ -40,14 +36,11 @@ class SharedLibraryFile; /// /// The base class LinkingContext contains the options needed by core linking. /// Subclasses of LinkingContext have additional options needed by specific -/// Readers -/// and Writers. For example, ELFLinkingContext has methods that supplies -/// options -/// to the ELF Reader and Writer. +/// Readers and Writers. For example, ELFLinkingContext has methods that +/// supplies options to the ELF Reader and Writer. class LinkingContext { public: - /// \brief The types of output file that the linker - /// creates. + /// \brief The types of output file that the linker creates. enum class OutputFileType : uint8_t { Default, // The default output type for this target YAML, // The output type is set to YAML @@ -82,6 +75,7 @@ public: /// reference). Only Atoms with scope scopeLinkageUnit or scopeGlobal can /// be kept live using this method. const std::vector &deadStripRoots() const { + assert(_deadStrip && "only applicable when deadstripping enabled"); return _deadStripRoots; } @@ -226,14 +220,14 @@ public: /// This method adds undefined symbols specified by the -u option to the to /// the list of undefined symbols known to the linker. This option essentially - /// forces an undefined symbol to be create. You may also need to call + /// forces an undefined symbol to be created. You may also need to call /// addDeadStripRoot() for the symbol if your platform supports dead /// stripping, so that the symbol will not be removed from the output. void addInitialUndefinedSymbol(StringRef symbolName) { _initialUndefinedSymbols.push_back(symbolName); } - /// Iterators for symbols that appear on the command line + /// Iterators for symbols that appear on the command line. typedef std::vector StringRefVector; typedef StringRefVector::iterator StringRefVectorIter; typedef StringRefVector::const_iterator StringRefVectorConstIter; @@ -280,7 +274,7 @@ public: return true; } - /// Returns the output file that that the linker needs to create + /// Returns the output file type that that the linker needs to create. OutputFileType outputFileType() const { return _outputFileType; } /// Returns the YAML reader. @@ -289,7 +283,7 @@ public: /// Returns the LLD Native file format reader. virtual Reader &getNativeReader() const { return *_nativeReader; } - /// Return the default reader for the target + /// Return the default reader for the target. virtual Reader &getDefaultReader() const = 0; /// This method is called by core linking to give the Writer a chance diff --git a/lld/include/lld/Core/Reference.h b/lld/include/lld/Core/Reference.h index 1af2e987d2fc..bd5e30001302 100644 --- a/lld/include/lld/Core/Reference.h +++ b/lld/include/lld/Core/Reference.h @@ -10,7 +10,8 @@ #ifndef LLD_CORE_REFERENCES_H #define LLD_CORE_REFERENCES_H -#include "llvm/Support/DataTypes.h" +#include "lld/Core/LLVM.h" + #include "llvm/ADT/StringSwitch.h" namespace lld { diff --git a/lld/include/lld/Core/SharedLibraryAtom.h b/lld/include/lld/Core/SharedLibraryAtom.h index 76a7d0a2f0c3..1583739befb4 100644 --- a/lld/include/lld/Core/SharedLibraryAtom.h +++ b/lld/include/lld/Core/SharedLibraryAtom.h @@ -12,10 +12,6 @@ #include "lld/Core/Atom.h" -namespace llvm { - class StringRef; -} - namespace lld { /// A SharedLibraryAtom has no content. diff --git a/lld/include/lld/Core/SharedLibraryFile.h b/lld/include/lld/Core/SharedLibraryFile.h index bdbe1f4d2146..42827f9759c3 100644 --- a/lld/include/lld/Core/SharedLibraryFile.h +++ b/lld/include/lld/Core/SharedLibraryFile.h @@ -11,7 +11,6 @@ #define LLD_CORE_SHARED_LIBRARY_FILE_H #include "lld/Core/File.h" -#include "lld/Core/SharedLibraryAtom.h" namespace lld { diff --git a/lld/include/lld/Core/SymbolTable.h b/lld/include/lld/Core/SymbolTable.h index a9d7a1e8a3bb..a509374008c8 100644 --- a/lld/include/lld/Core/SymbolTable.h +++ b/lld/include/lld/Core/SymbolTable.h @@ -14,7 +14,6 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringRef.h" #include #include diff --git a/lld/include/lld/Core/UndefinedAtom.h b/lld/include/lld/Core/UndefinedAtom.h index 5bb14e8c007d..4a6e2a0a1d89 100644 --- a/lld/include/lld/Core/UndefinedAtom.h +++ b/lld/include/lld/Core/UndefinedAtom.h @@ -15,7 +15,7 @@ namespace lld { /// An UndefinedAtom has no content. -/// It exists as a place holder for a future atom. +/// It exists as a placeholder for a future atom. class UndefinedAtom : public Atom { public: /// Whether this undefined symbol needs to be resolved, diff --git a/lld/include/lld/Driver/GnuLdInputGraph.h b/lld/include/lld/Driver/GnuLdInputGraph.h index 00594b14e87f..68c66b29aa8e 100644 --- a/lld/include/lld/Driver/GnuLdInputGraph.h +++ b/lld/include/lld/Driver/GnuLdInputGraph.h @@ -101,7 +101,7 @@ private: /// \brief Represents a ELF control node class ELFGroup : public Group { public: - ELFGroup(ELFLinkingContext &ctx, int64_t ordinal) + ELFGroup(const ELFLinkingContext &ctx, int64_t ordinal) : Group(ordinal), _elfLinkingContext(ctx) {} static inline bool classof(const InputElement *a) { diff --git a/lld/include/lld/Passes/LayoutPass.h b/lld/include/lld/Passes/LayoutPass.h index 08fdbec84a79..052653fd9354 100644 --- a/lld/include/lld/Passes/LayoutPass.h +++ b/lld/include/lld/Passes/LayoutPass.h @@ -10,11 +10,8 @@ #ifndef LLD_PASSES_LAYOUT_PASS_H #define LLD_PASSES_LAYOUT_PASS_H -#include "lld/Core/Atom.h" #include "lld/Core/File.h" #include "lld/Core/Pass.h" -#include "lld/Core/range.h" -#include "lld/Core/Reference.h" #include "llvm/ADT/DenseMap.h" @@ -89,10 +86,8 @@ private: void undecorate(MutableFile::DefinedAtomRange &atomRange, std::vector &keys) const; -#ifndef NDEBUG // Check if the follow-on graph is a correct structure. For debugging only. void checkFollowonChain(MutableFile::DefinedAtomRange &range); -#endif }; } // namespace lld diff --git a/lld/include/lld/Passes/RoundTripNativePass.h b/lld/include/lld/Passes/RoundTripNativePass.h index 0d562ed58e1b..074a57e43e3a 100644 --- a/lld/include/lld/Passes/RoundTripNativePass.h +++ b/lld/include/lld/Passes/RoundTripNativePass.h @@ -14,7 +14,6 @@ #include "lld/Core/LinkingContext.h" #include "lld/Core/Pass.h" -#include #include namespace lld { diff --git a/lld/include/lld/Passes/RoundTripYAMLPass.h b/lld/include/lld/Passes/RoundTripYAMLPass.h index 772bc79455eb..ef518bccae79 100644 --- a/lld/include/lld/Passes/RoundTripYAMLPass.h +++ b/lld/include/lld/Passes/RoundTripYAMLPass.h @@ -14,7 +14,6 @@ #include "lld/Core/LinkingContext.h" #include "lld/Core/Pass.h" -#include #include namespace lld { diff --git a/lld/include/lld/ReaderWriter/AtomLayout.h b/lld/include/lld/ReaderWriter/AtomLayout.h index e182464908b9..ad4cd0607b88 100644 --- a/lld/include/lld/ReaderWriter/AtomLayout.h +++ b/lld/include/lld/ReaderWriter/AtomLayout.h @@ -10,8 +10,6 @@ #ifndef LLD_READER_WRITER_ATOM_LAYOUT_H #define LLD_READER_WRITER_ATOM_LAYOUT_H -#include - namespace lld { class Atom; diff --git a/lld/include/lld/ReaderWriter/FileArchive.h b/lld/include/lld/ReaderWriter/FileArchive.h index 8af9dfd24057..6a73da0f99cf 100644 --- a/lld/include/lld/ReaderWriter/FileArchive.h +++ b/lld/include/lld/ReaderWriter/FileArchive.h @@ -49,7 +49,7 @@ private: atom_collection_vector _undefinedAtoms; atom_collection_vector _sharedLibraryAtoms; atom_collection_vector _absoluteAtoms; - bool _isWholeArchive; + const bool _isWholeArchive; std::unordered_map _symbolMemberMap; }; diff --git a/lld/include/lld/ReaderWriter/MachOLinkingContext.h b/lld/include/lld/ReaderWriter/MachOLinkingContext.h index a26ddc12024c..314d8db5578a 100644 --- a/lld/include/lld/ReaderWriter/MachOLinkingContext.h +++ b/lld/include/lld/ReaderWriter/MachOLinkingContext.h @@ -165,8 +165,6 @@ private: mutable std::unique_ptr _kindHandler; mutable std::unique_ptr _machoReader; mutable std::unique_ptr _writer; - - }; } // end namespace lld diff --git a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h index dd5f27bd7c0d..6db00a4afeb2 100644 --- a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h +++ b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h @@ -10,10 +10,6 @@ #ifndef LLD_READER_WRITER_PECOFF_LINKING_CONTEXT_H #define LLD_READER_WRITER_PECOFF_LINKING_CONTEXT_H -#include -#include -#include - #include "lld/Core/LinkingContext.h" #include "lld/ReaderWriter/Reader.h" #include "lld/ReaderWriter/Writer.h" @@ -24,6 +20,10 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileUtilities.h" +#include +#include +#include + using llvm::COFF::MachineTypes; using llvm::COFF::WindowsSubsystem; diff --git a/lld/include/lld/ReaderWriter/Writer.h b/lld/include/lld/ReaderWriter/Writer.h index 2f33bb38a395..bea873a1cb6f 100644 --- a/lld/include/lld/ReaderWriter/Writer.h +++ b/lld/include/lld/ReaderWriter/Writer.h @@ -16,8 +16,8 @@ #include namespace lld { -class ELFLinkingContext; class File; +class ELFLinkingContext; class MachOLinkingContext; class PECOFFLinkingContext; class LinkingContext; @@ -44,8 +44,8 @@ protected: std::unique_ptr createWriterELF(const ELFLinkingContext &); std::unique_ptr createWriterMachO(const MachOLinkingContext &); -std::unique_ptr createWriterNative(const LinkingContext &); std::unique_ptr createWriterPECOFF(const PECOFFLinkingContext &); +std::unique_ptr createWriterNative(const LinkingContext &); std::unique_ptr createWriterYAML(const LinkingContext &); } // end namespace lld