[lld] r286030 - 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 18:00:57 PDT 2016


Author: eugenezelenko
Date: Fri Nov  4 20:00:56 2016
New Revision: 286030

URL: http://llvm.org/viewvc/llvm-project?rev=286030&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/D26320

Modified:
    lld/trunk/ELF/LTO.cpp
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/LinkerScript.h
    lld/trunk/ELF/Thunks.cpp
    lld/trunk/include/lld/Core/Pass.h
    lld/trunk/include/lld/Core/Reference.h
    lld/trunk/lib/Core/File.cpp
    lld/trunk/lib/Core/Reader.cpp
    lld/trunk/lib/Core/Writer.cpp

Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=286030&r1=286029&r2=286030&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Fri Nov  4 20:00:56 2016
@@ -12,9 +12,27 @@
 #include "Error.h"
 #include "InputFiles.h"
 #include "Symbols.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/LTO/Config.h"
 #include "llvm/LTO/LTO.h"
+#include "llvm/Object/SymbolicFile.h"
+#include "llvm/Support/CodeGen.h"
+#include "llvm/Support/ELF.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cstddef>
+#include <memory>
+#include <string>
+#include <system_error>
+#include <vector>
 
 using namespace llvm;
 using namespace llvm::object;
@@ -76,7 +94,7 @@ static std::unique_ptr<lto::LTO> createL
 
 BitcodeCompiler::BitcodeCompiler() : LtoObj(createLTO()) {}
 
-BitcodeCompiler::~BitcodeCompiler() {}
+BitcodeCompiler::~BitcodeCompiler() = default;
 
 static void undefine(Symbol *S) {
   replaceBody<Undefined>(S, S->body()->getName(), STV_DEFAULT, S->body()->Type,
@@ -125,7 +143,7 @@ std::vector<InputFile *> BitcodeCompiler
 
   checkError(LtoObj->run([&](size_t Task) {
     return llvm::make_unique<lto::NativeObjectStream>(
-        llvm::make_unique<llvm::raw_svector_ostream>(Buff[Task]));
+        llvm::make_unique<raw_svector_ostream>(Buff[Task]));
   }));
 
   for (unsigned I = 0; I != MaxTasks; ++I) {

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=286030&r1=286029&r2=286030&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Nov  4 20:00:56 2016
@@ -29,11 +29,28 @@
 #include "Symbols.h"
 #include "Target.h"
 #include "Writer.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ELF.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <iterator>
+#include <limits>
+#include <memory>
+#include <string>
+#include <tuple>
+#include <vector>
 
 using namespace llvm;
 using namespace llvm::ELF;
@@ -104,8 +121,8 @@ template <class ELFT> static bool isDisc
   return !S || !S->Live;
 }
 
-template <class ELFT> LinkerScript<ELFT>::LinkerScript() {}
-template <class ELFT> LinkerScript<ELFT>::~LinkerScript() {}
+template <class ELFT> LinkerScript<ELFT>::LinkerScript() = default;
+template <class ELFT> LinkerScript<ELFT>::~LinkerScript() = default;
 
 template <class ELFT>
 bool LinkerScript<ELFT>::shouldKeep(InputSectionBase<ELFT> *S) {
@@ -293,7 +310,6 @@ void LinkerScript<ELFT>::addSection(Outp
 
 template <class ELFT>
 void LinkerScript<ELFT>::processCommands(OutputSectionFactory<ELFT> &Factory) {
-
   for (unsigned I = 0; I < Opt.Commands.size(); ++I) {
     auto Iter = Opt.Commands.begin() + I;
     const std::unique_ptr<BaseCommand> &Base1 = *Iter;
@@ -609,7 +625,6 @@ void LinkerScript<ELFT>::assignAddresses
 
     // Continue from where we found it.
     CmdIndex = (Pos - Opt.Commands.begin()) + 1;
-    continue;
   }
 
   // Assign addresses as instructed by linker script SECTIONS sub-commands.

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=286030&r1=286029&r2=286030&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Fri Nov  4 20:00:56 2016
@@ -14,15 +14,19 @@
 #include "Strings.h"
 #include "Writer.h"
 #include "lld/Core/LLVM.h"
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/MapVector.h"
-#include "llvm/Support/Allocator.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include <functional>
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <vector>
 
 namespace lld {
 namespace elf {
+
 class DefinedCommon;
 class ScriptParser;
 class SymbolBody;
@@ -67,7 +71,9 @@ enum SectionsCommandKind {
 
 struct BaseCommand {
   BaseCommand(int K) : Kind(K) {}
-  virtual ~BaseCommand() {}
+
+  virtual ~BaseCommand() = default;
+
   int Kind;
 };
 
@@ -75,6 +81,7 @@ struct BaseCommand {
 struct SymbolAssignment : BaseCommand {
   SymbolAssignment(StringRef Name, Expr E)
       : BaseCommand(AssignmentKind), Name(Name), Expression(E) {}
+
   static bool classof(const BaseCommand *C);
 
   // The LHS of an expression. Name is either a symbol name or ".".
@@ -98,7 +105,9 @@ enum class ConstraintKind { NoConstraint
 struct OutputSectionCommand : BaseCommand {
   OutputSectionCommand(StringRef Name)
       : BaseCommand(OutputSectionKind), Name(Name) {}
+
   static bool classof(const BaseCommand *C);
+
   StringRef Name;
   Expr AddrExpr;
   Expr AlignExpr;
@@ -126,7 +135,9 @@ struct SectionPattern {
 struct InputSectionDescription : BaseCommand {
   InputSectionDescription(StringRef FilePattern)
       : BaseCommand(InputSectionKind), FilePat({FilePattern}) {}
+
   static bool classof(const BaseCommand *C);
+
   StringMatcher FilePat;
 
   // Input sections that matches at least one of SectionPatterns
@@ -139,7 +150,9 @@ struct InputSectionDescription : BaseCom
 // Represents an ASSERT().
 struct AssertCommand : BaseCommand {
   AssertCommand(Expr E) : BaseCommand(AssertKind), Expression(E) {}
+
   static bool classof(const BaseCommand *C);
+
   Expr Expression;
 };
 
@@ -147,7 +160,9 @@ struct AssertCommand : BaseCommand {
 struct BytesDataCommand : BaseCommand {
   BytesDataCommand(uint64_t Data, unsigned Size)
       : BaseCommand(BytesDataKind), Data(Data), Size(Size) {}
+
   static bool classof(const BaseCommand *C);
+
   uint64_t Data;
   unsigned Offset;
   unsigned Size;
@@ -201,6 +216,7 @@ template <class ELFT> class LinkerScript
 public:
   LinkerScript();
   ~LinkerScript();
+
   void processCommands(OutputSectionFactory<ELFT> &Factory);
   void createSections(OutputSectionFactory<ELFT> &Factory);
   void adjustSectionsBeforeSorting();
@@ -263,7 +279,7 @@ template <class ELFT> LinkerScript<ELFT>
 
 extern LinkerScriptBase *ScriptBase;
 
-} // namespace elf
-} // namespace lld
+} // end namespace elf
+} // end namespace lld
 
-#endif
+#endif // LLD_ELF_LINKER_SCRIPT_H

Modified: lld/trunk/ELF/Thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.cpp?rev=286030&r1=286029&r2=286030&view=diff
==============================================================================
--- lld/trunk/ELF/Thunks.cpp (original)
+++ lld/trunk/ELF/Thunks.cpp Fri Nov  4 20:00:56 2016
@@ -22,18 +22,20 @@
 //===---------------------------------------------------------------------===//
 
 #include "Thunks.h"
+#include "Config.h"
 #include "Error.h"
-#include "InputFiles.h"
 #include "InputSection.h"
 #include "Memory.h"
 #include "OutputSections.h"
 #include "Symbols.h"
 #include "Target.h"
-#include "llvm/Support/Allocator.h"
-
-#include "llvm/Object/ELF.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/Endian.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
+#include <cstdint>
+#include <cstring>
 
 using namespace llvm;
 using namespace llvm::object;
@@ -44,6 +46,7 @@ namespace lld {
 namespace elf {
 
 namespace {
+
 // Specific ARM Thunk implementations. The naming convention is:
 // Source State, TargetState, Target Requirement, ABS or PI, Range
 template <class ELFT>
@@ -97,7 +100,8 @@ public:
   uint32_t size() const override { return 16; }
   void writeTo(uint8_t *Buf) const override;
 };
-} // anonymous namespace
+
+} // end anonymous namespace
 
 // ARM Target Thunks
 template <class ELFT> static uint64_t getARMThunkDestVA(const SymbolBody &S) {
@@ -182,7 +186,7 @@ template <class ELFT> typename ELFT::uin
   return Owner.OutSec->getVA() + Owner.OutSecOff + Offset;
 }
 
-template <class ELFT> Thunk<ELFT>::~Thunk() {}
+template <class ELFT> Thunk<ELFT>::~Thunk() = default;
 
 // Creates a thunk for Thumb-ARM interworking.
 template <class ELFT>
@@ -265,5 +269,5 @@ template class Thunk<ELF32BE>;
 template class Thunk<ELF64LE>;
 template class Thunk<ELF64BE>;
 
-} // namespace elf
-} // namespace lld
+} // end namespace elf
+} // end namespace lld

Modified: lld/trunk/include/lld/Core/Pass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Pass.h?rev=286030&r1=286029&r2=286030&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Pass.h (original)
+++ lld/trunk/include/lld/Core/Pass.h Fri Nov  4 20:00:56 2016
@@ -1,4 +1,4 @@
-//===------ Core/Pass.h - Base class for linker passes --------------------===//
+//===------ Core/Pass.h - Base class for linker passes ----------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -10,13 +10,10 @@
 #ifndef LLD_CORE_PASS_H
 #define LLD_CORE_PASS_H
 
-#include "lld/Core/Atom.h"
-#include "lld/Core/File.h"
-#include "lld/Core/Reference.h"
 #include "llvm/Support/Error.h"
-#include <vector>
 
 namespace lld {
+
 class SimpleFile;
 
 /// Once the core linking is done (which resolves references, coalesces atoms
@@ -31,16 +28,16 @@ class SimpleFile;
 /// new Atoms to the graph using the File's addAtom() method.
 class Pass {
 public:
-  virtual ~Pass() { }
+  virtual ~Pass() = default;
 
   /// Do the actual work of the Pass.
   virtual llvm::Error perform(SimpleFile &mergedFile) = 0;
 
 protected:
   // Only subclassess can be instantiated.
-  Pass() { }
+  Pass() = default;
 };
 
-} // namespace lld
+} // end namespace lld
 
 #endif // LLD_CORE_PASS_H

Modified: lld/trunk/include/lld/Core/Reference.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Reference.h?rev=286030&r1=286029&r2=286030&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Reference.h (original)
+++ lld/trunk/include/lld/Core/Reference.h Fri Nov  4 20:00:56 2016
@@ -1,4 +1,4 @@
-//===- Core/References.h - A Reference to Another Atom --------------------===//
+//===- Core/References.h - A Reference to Another Atom ----------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -10,10 +10,10 @@
 #ifndef LLD_CORE_REFERENCES_H
 #define LLD_CORE_REFERENCES_H
 
-#include "lld/Core/LLVM.h"
-#include "llvm/ADT/StringSwitch.h"
+#include <cstdint>
 
 namespace lld {
+
 class Atom;
 
 ///
@@ -107,13 +107,13 @@ protected:
   /// object.  Therefore, no one but the owning File object should call
   /// delete on an Reference.  In fact, some File objects may bulk allocate
   /// an array of References, so they cannot be individually deleted by anyone.
-  virtual ~Reference() {}
+  virtual ~Reference() = default;
 
   KindValue  _kindValue;
   uint8_t    _kindNamespace;
   uint8_t    _kindArch;
 };
 
-} // namespace lld
+} // end namespace lld
 
 #endif // LLD_CORE_REFERENCES_H

Modified: lld/trunk/lib/Core/File.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/File.cpp?rev=286030&r1=286029&r2=286030&view=diff
==============================================================================
--- lld/trunk/lib/Core/File.cpp (original)
+++ lld/trunk/lib/Core/File.cpp Fri Nov  4 20:00:56 2016
@@ -8,12 +8,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "lld/Core/File.h"
-#include "lld/Core/LLVM.h"
 #include <mutex>
 
 namespace lld {
 
-File::~File() { }
+File::~File() = default;
 
 File::AtomVector<DefinedAtom> File::_noDefinedAtoms;
 File::AtomVector<UndefinedAtom> File::_noUndefinedAtoms;
@@ -27,4 +26,4 @@ std::error_code File::parse() {
   return _lastError.getValue();
 }
 
-} // namespace lld
+} // end namespace lld

Modified: lld/trunk/lib/Core/Reader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Reader.cpp?rev=286030&r1=286029&r2=286030&view=diff
==============================================================================
--- lld/trunk/lib/Core/Reader.cpp (original)
+++ lld/trunk/lib/Core/Reader.cpp Fri Nov  4 20:00:56 2016
@@ -9,16 +9,17 @@
 
 #include "lld/Core/File.h"
 #include "lld/Core/Reader.h"
+#include "lld/Core/Reference.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
-#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include <memory>
-#include <system_error>
+#include <algorithm>
 
 namespace lld {
 
-YamlIOTaggedDocumentHandler::~YamlIOTaggedDocumentHandler() {}
+YamlIOTaggedDocumentHandler::~YamlIOTaggedDocumentHandler() = default;
 
 void Registry::add(std::unique_ptr<Reader> reader) {
   _readers.push_back(std::move(reader));
@@ -63,7 +64,6 @@ bool Registry::handleTaggedDoc(llvm::yam
   return false;
 }
 
-
 void Registry::addKindTable(Reference::KindNamespace ns,
                             Reference::KindArch arch,
                             const KindStrings array[]) {

Modified: lld/trunk/lib/Core/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Writer.cpp?rev=286030&r1=286029&r2=286030&view=diff
==============================================================================
--- lld/trunk/lib/Core/Writer.cpp (original)
+++ lld/trunk/lib/Core/Writer.cpp Fri Nov  4 20:00:56 2016
@@ -7,13 +7,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lld/Core/File.h"
 #include "lld/Core/Writer.h"
 
 namespace lld {
-Writer::Writer() {
-}
 
-Writer::~Writer() {
-}
+Writer::Writer() = default;
+
+Writer::~Writer() = default;
+
 } // end namespace lld




More information about the llvm-commits mailing list