Index: include/lld/Core/Atom.h =================================================================== --- include/lld/Core/Atom.h +++ include/lld/Core/Atom.h @@ -1,4 +1,4 @@ -//===- Core/Atom.h - A node in linking graph ------------------------------===// +//===- Core/Atom.h - A node in linking graph --------------------*- C++ -*-===// // // The LLVM Linker // @@ -11,6 +11,7 @@ #define LLD_CORE_ATOM_H #include "lld/Core/LLVM.h" +#include "llvm/ADT/StringRef.h" namespace lld { @@ -28,6 +29,7 @@ /// class Atom { template friend class OwningAtomPtr; + public: /// Whether this atom is defined or a proxy for an undefined symbol enum Definition { @@ -47,7 +49,6 @@ /// loader (e.g. visibility=default). }; - /// file - returns the File that produced/owns this Atom virtual const File& file() const = 0; @@ -69,7 +70,7 @@ /// object. Therefore, no one but the owning File object should call /// delete on an Atom. In fact, some File objects may bulk allocate /// an array of Atoms, so they cannot be individually deleted by anyone. - virtual ~Atom() {} + virtual ~Atom() = default; private: Definition _definition; @@ -81,9 +82,10 @@ class OwningAtomPtr { private: OwningAtomPtr(const OwningAtomPtr &) = delete; - void operator=(const OwningAtomPtr&) = delete; + void operator=(const OwningAtomPtr &) = delete; + public: - OwningAtomPtr() : atom(nullptr) { } + OwningAtomPtr() = default; OwningAtomPtr(T *atom) : atom(atom) { } ~OwningAtomPtr() { @@ -121,9 +123,9 @@ } private: - T *atom; + T *atom = nullptr; }; -} // namespace lld +} // end namespace lld #endif // LLD_CORE_ATOM_H Index: include/lld/Core/LinkingContext.h =================================================================== --- include/lld/Core/LinkingContext.h +++ include/lld/Core/LinkingContext.h @@ -1,4 +1,4 @@ -//===- lld/Core/LinkingContext.h - Linker Target Info Interface -----------===// +//===- lld/Core/LinkingContext.h - Linker Target Info Interface -*- C++ -*-===// // // The LLVM Linker // @@ -10,17 +10,21 @@ #ifndef LLD_CORE_LINKING_CONTEXT_H #define LLD_CORE_LINKING_CONTEXT_H -#include "lld/Core/Error.h" -#include "lld/Core/LLVM.h" #include "lld/Core/Node.h" -#include "lld/Core/Reference.h" #include "lld/Core/Reader.h" -#include "llvm/Support/ErrorOr.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include #include #include namespace lld { + class PassManager; class File; class Writer; @@ -117,12 +121,15 @@ void setDeadStripping(bool enable) { _deadStrip = enable; } void setGlobalsAreDeadStripRoots(bool v) { _globalsAreDeadStripRoots = v; } + void setPrintRemainingUndefines(bool print) { _printRemainingUndefines = print; } + void setAllowRemainingUndefines(bool allow) { _allowRemainingUndefines = allow; } + void setAllowShlibUndefines(bool allow) { _allowShlibUndefines = allow; } void setLogInputFiles(bool log) { _logInputFiles = log; } @@ -248,4 +255,4 @@ } // end namespace lld -#endif +#endif // LLD_CORE_LINKING_CONTEXT_H Index: include/lld/Core/Node.h =================================================================== --- include/lld/Core/Node.h +++ include/lld/Core/Node.h @@ -1,4 +1,4 @@ -//===- lld/Core/Node.h - Input file class ---------------------------------===// +//===- lld/Core/Node.h - Input file class -----------------------*- C++ -*-===// // // The LLVM Linker // @@ -17,9 +17,8 @@ #define LLD_CORE_NODE_H #include "lld/Core/File.h" -#include "llvm/Option/ArgList.h" +#include #include -#include namespace lld { @@ -29,8 +28,10 @@ class Node { public: enum class Kind { File, GroupEnd }; + explicit Node(Kind type) : _kind(type) {} - virtual ~Node() {} + virtual ~Node() = default; + virtual Kind kind() const { return _kind; } private: @@ -69,6 +70,6 @@ std::unique_ptr _file; }; -} // namespace lld +} // end namespace lld #endif // LLD_CORE_NODE_H Index: include/lld/Core/Reader.h =================================================================== --- include/lld/Core/Reader.h +++ include/lld/Core/Reader.h @@ -10,11 +10,11 @@ #ifndef LLD_CORE_READER_H #define LLD_CORE_READER_H -#include "lld/Core/LLVM.h" #include "lld/Core/Reference.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/YAMLTraits.h" -#include +#include "llvm/Support/MemoryBuffer.h" #include #include @@ -23,10 +23,11 @@ namespace llvm { namespace yaml { class IO; -} -} +} // end namespace yaml +} // end namespace llvm namespace lld { + class File; class LinkingContext; class MachOLinkingContext; @@ -37,7 +38,7 @@ /// Each file format (e.g. mach-o, etc) has a concrete subclass of Reader. class Reader { public: - virtual ~Reader() {} + virtual ~Reader() = default; /// Sniffs the file to determine if this Reader can parse it. /// The method is called with: @@ -52,7 +53,6 @@ loadFile(std::unique_ptr mb, const class Registry &) const = 0; }; - /// \brief An abstract class for handling alternate yaml representations /// of object files. /// @@ -74,7 +74,6 @@ virtual bool handledDocTag(llvm::yaml::IO &io, const lld::File *&f) const = 0; }; - /// A registry to hold the list of currently registered Readers and /// tables which map Reference kind values to strings. /// The linker does not directly invoke Readers. Instead, it registers @@ -127,7 +126,6 @@ void addKindTable(Reference::KindNamespace ns, Reference::KindArch arch, const KindStrings array[]); - private: struct KindEntry { Reference::KindNamespace ns; @@ -154,4 +152,4 @@ } // end namespace lld -#endif +#endif // LLD_CORE_READER_H Index: lib/Core/LinkingContext.cpp =================================================================== --- lib/Core/LinkingContext.cpp +++ lib/Core/LinkingContext.cpp @@ -8,16 +8,17 @@ //===----------------------------------------------------------------------===// #include "lld/Core/LinkingContext.h" -#include "lld/Core/Resolver.h" +#include "lld/Core/File.h" +#include "lld/Core/Node.h" #include "lld/Core/Simple.h" #include "lld/Core/Writer.h" -#include "llvm/ADT/Triple.h" +#include namespace lld { -LinkingContext::LinkingContext() {} +LinkingContext::LinkingContext() = default; -LinkingContext::~LinkingContext() {} +LinkingContext::~LinkingContext() = default; bool LinkingContext::validate(raw_ostream &diagnostics) { return validateImpl(diagnostics); Index: lib/Driver/DarwinLdDriver.cpp =================================================================== --- lib/Driver/DarwinLdDriver.cpp +++ lib/Driver/DarwinLdDriver.cpp @@ -14,24 +14,45 @@ //===----------------------------------------------------------------------===// #include "lld/Core/ArchiveLibraryFile.h" +#include "lld/Core/Error.h" #include "lld/Core/File.h" #include "lld/Core/Instrumentation.h" +#include "lld/Core/LLVM.h" +#include "lld/Core/Node.h" #include "lld/Core/PassManager.h" #include "lld/Core/Resolver.h" #include "lld/Core/SharedLibraryFile.h" -#include "lld/Driver/Driver.h" +#include "lld/Core/Simple.h" +#include "lld/Core/LinkingContext.h" #include "lld/ReaderWriter/MachOLinkingContext.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/Triple.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" #include "llvm/Option/Arg.h" +#include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" +#include "llvm/Option/OptTable.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Error.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/Format.h" +#include "llvm/Support/MachO.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include +#include using namespace lld; @@ -116,7 +137,7 @@ return files; } -} // anonymous namespace +} // end anonymous namespace // Test may be running on Windows. Canonicalize the path // separator to '/' to get consistent outputs for tests. @@ -166,8 +187,6 @@ return std::error_code(); } - - /// Order files are one symbol per line. Blank lines are ignored. /// Trailing comments start with #. Symbol names can be prefixed with an /// architecture name and/or .o leaf name. Examples: @@ -1213,5 +1232,6 @@ return true; } -} // namespace mach_o -} // namespace lld + +} // end namespace mach_o +} // end namespace lld