[lld] r286000 - Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.

Eugene Zelenko via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 4 10:39:46 PDT 2016


Author: eugenezelenko
Date: Fri Nov  4 12:39:46 2016
New Revision: 286000

URL: http://llvm.org/viewvc/llvm-project?rev=286000&view=rev
Log:
Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.

Differential revision: https://reviews.llvm.org/D26293

Modified:
    lld/trunk/include/lld/Core/Atom.h
    lld/trunk/include/lld/Core/LinkingContext.h
    lld/trunk/include/lld/Core/Node.h
    lld/trunk/include/lld/Core/Reader.h
    lld/trunk/lib/Core/LinkingContext.cpp
    lld/trunk/lib/Driver/DarwinLdDriver.cpp

Modified: lld/trunk/include/lld/Core/Atom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Atom.h?rev=286000&r1=285999&r2=286000&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Atom.h (original)
+++ lld/trunk/include/lld/Core/Atom.h Fri Nov  4 12:39:46 2016
@@ -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 OwningAtomPtr;
 ///
 class Atom {
   template<typename T> friend class OwningAtomPtr;
+
 public:
   /// Whether this atom is defined or a proxy for an undefined symbol
   enum Definition {
@@ -47,7 +49,6 @@ public:
                            ///  loader (e.g. visibility=default).
   };
 
-
   /// file - returns the File that produced/owns this Atom
   virtual const File& file() const = 0;
 
@@ -69,7 +70,7 @@ protected:
   /// 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 @@ template<typename T>
 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 @@ public:
   }
 
 private:
-  T *atom;
+  T *atom = nullptr;
 };
 
-} // namespace lld
+} // end namespace lld
 
 #endif // LLD_CORE_ATOM_H

Modified: lld/trunk/include/lld/Core/LinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=286000&r1=285999&r2=286000&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LinkingContext.h (original)
+++ lld/trunk/include/lld/Core/LinkingContext.h Fri Nov  4 12:39:46 2016
@@ -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 <cassert>
+#include <cstdint>
+#include <memory>
 #include <string>
 #include <vector>
 
 namespace lld {
+
 class PassManager;
 class File;
 class Writer;
@@ -117,12 +121,15 @@ public:
 
   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; }
 
@@ -149,7 +156,7 @@ public:
   /// during link. Flavors can override this function in their LinkingContext
   /// to add more internal files. These internal files are positioned before
   /// the actual input files.
-  virtual void createInternalFiles(std::vector<std::unique_ptr<File> > &) const;
+  virtual void createInternalFiles(std::vector<std::unique_ptr<File>> &) const;
 
   /// Return the list of undefined symbols that are specified in the
   /// linker command line, using the -u option.
@@ -248,4 +255,4 @@ private:
 
 } // end namespace lld
 
-#endif
+#endif // LLD_CORE_LINKING_CONTEXT_H

Modified: lld/trunk/include/lld/Core/Node.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Node.h?rev=286000&r1=285999&r2=286000&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Node.h (original)
+++ lld/trunk/include/lld/Core/Node.h Fri Nov  4 12:39:46 2016
@@ -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 <algorithm>
 #include <memory>
-#include <vector>
 
 namespace lld {
 
@@ -29,8 +28,10 @@ namespace lld {
 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 @@ protected:
   std::unique_ptr<File> _file;
 };
 
-} // namespace lld
+} // end namespace lld
 
 #endif // LLD_CORE_NODE_H

Modified: lld/trunk/include/lld/Core/Reader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Reader.h?rev=286000&r1=285999&r2=286000&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Reader.h (original)
+++ lld/trunk/include/lld/Core/Reader.h Fri Nov  4 12:39:46 2016
@@ -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 <functional>
+#include "llvm/Support/MemoryBuffer.h"
 #include <memory>
 #include <vector>
 
@@ -23,10 +23,11 @@ using llvm::sys::fs::file_magic;
 namespace llvm {
 namespace yaml {
 class IO;
-}
-}
+} // end namespace yaml
+} // end namespace llvm
 
 namespace lld {
+
 class File;
 class LinkingContext;
 class MachOLinkingContext;
@@ -37,7 +38,7 @@ class MachOLinkingContext;
 /// 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 @@ public:
   loadFile(std::unique_ptr<MemoryBuffer> mb, const class Registry &) const = 0;
 };
 
-
 /// \brief An abstract class for handling alternate yaml representations
 /// of object files.
 ///
@@ -74,7 +74,6 @@ public:
   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 @@ public:
   void addKindTable(Reference::KindNamespace ns, Reference::KindArch arch,
                     const KindStrings array[]);
 
-
 private:
   struct KindEntry {
     Reference::KindNamespace  ns;
@@ -154,4 +152,4 @@ private:
 
 } // end namespace lld
 
-#endif
+#endif // LLD_CORE_READER_H

Modified: lld/trunk/lib/Core/LinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/LinkingContext.cpp?rev=286000&r1=285999&r2=286000&view=diff
==============================================================================
--- lld/trunk/lib/Core/LinkingContext.cpp (original)
+++ lld/trunk/lib/Core/LinkingContext.cpp Fri Nov  4 12:39:46 2016
@@ -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 <algorithm>
 
 namespace lld {
 
-LinkingContext::LinkingContext() {}
+LinkingContext::LinkingContext() = default;
 
-LinkingContext::~LinkingContext() {}
+LinkingContext::~LinkingContext() = default;
 
 bool LinkingContext::validate(raw_ostream &diagnostics) {
   return validateImpl(diagnostics);
@@ -59,7 +60,7 @@ LinkingContext::createUndefinedSymbolFil
 }
 
 void LinkingContext::createInternalFiles(
-    std::vector<std::unique_ptr<File> > &result) const {
+    std::vector<std::unique_ptr<File>> &result) const {
   if (std::unique_ptr<File> file = createEntrySymbolFile())
     result.push_back(std::move(file));
   if (std::unique_ptr<File> file = createUndefinedSymbolFile())

Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=286000&r1=285999&r2=286000&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Fri Nov  4 12:39:46 2016
@@ -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 <algorithm>
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <system_error>
+#include <utility>
+#include <vector>
 
 using namespace lld;
 
@@ -116,7 +137,7 @@ loadFile(MachOLinkingContext &ctx, Strin
   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 @@ static std::error_code parseExportsList(
   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 @@ bool link(llvm::ArrayRef<const char *> a
 
   return true;
 }
-} // namespace mach_o
-} // namespace lld
+
+} // end namespace mach_o
+} // end namespace lld




More information about the llvm-commits mailing list