Index: lld/trunk/ELF/LTO.cpp =================================================================== --- lld/trunk/ELF/LTO.cpp +++ lld/trunk/ELF/LTO.cpp @@ -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 +#include +#include +#include +#include +#include using namespace llvm; using namespace llvm::object; @@ -76,7 +94,7 @@ BitcodeCompiler::BitcodeCompiler() : LtoObj(createLTO()) {} -BitcodeCompiler::~BitcodeCompiler() {} +BitcodeCompiler::~BitcodeCompiler() = default; static void undefine(Symbol *S) { replaceBody(S, S->body()->getName(), STV_DEFAULT, S->body()->Type, @@ -125,7 +143,7 @@ checkError(LtoObj->run([&](size_t Task) { return llvm::make_unique( - llvm::make_unique(Buff[Task])); + llvm::make_unique(Buff[Task])); })); for (unsigned I = 0; I != MaxTasks; ++I) { Index: lld/trunk/ELF/LinkerScript.h =================================================================== --- lld/trunk/ELF/LinkerScript.h +++ lld/trunk/ELF/LinkerScript.h @@ -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 +#include +#include +#include +#include namespace lld { namespace elf { + class DefinedCommon; class ScriptParser; class SymbolBody; @@ -67,7 +71,9 @@ struct BaseCommand { BaseCommand(int K) : Kind(K) {} - virtual ~BaseCommand() {} + + virtual ~BaseCommand() = default; + int Kind; }; @@ -75,6 +81,7 @@ 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 @@ 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 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 @@ // 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 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 @@ public: LinkerScript(); ~LinkerScript(); + void processCommands(OutputSectionFactory &Factory); void createSections(OutputSectionFactory &Factory); void adjustSectionsBeforeSorting(); @@ -263,7 +279,7 @@ extern LinkerScriptBase *ScriptBase; -} // namespace elf -} // namespace lld +} // end namespace elf +} // end namespace lld -#endif +#endif // LLD_ELF_LINKER_SCRIPT_H Index: lld/trunk/ELF/LinkerScript.cpp =================================================================== --- lld/trunk/ELF/LinkerScript.cpp +++ lld/trunk/ELF/LinkerScript.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace llvm; using namespace llvm::ELF; @@ -104,8 +121,8 @@ return !S || !S->Live; } -template LinkerScript::LinkerScript() {} -template LinkerScript::~LinkerScript() {} +template LinkerScript::LinkerScript() = default; +template LinkerScript::~LinkerScript() = default; template bool LinkerScript::shouldKeep(InputSectionBase *S) { @@ -293,7 +310,6 @@ template void LinkerScript::processCommands(OutputSectionFactory &Factory) { - for (unsigned I = 0; I < Opt.Commands.size(); ++I) { auto Iter = Opt.Commands.begin() + I; const std::unique_ptr &Base1 = *Iter; @@ -609,7 +625,6 @@ // Continue from where we found it. CmdIndex = (Pos - Opt.Commands.begin()) + 1; - continue; } // Assign addresses as instructed by linker script SECTIONS sub-commands. Index: lld/trunk/ELF/Thunks.cpp =================================================================== --- lld/trunk/ELF/Thunks.cpp +++ lld/trunk/ELF/Thunks.cpp @@ -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 +#include using namespace llvm; using namespace llvm::object; @@ -44,6 +46,7 @@ namespace elf { namespace { + // Specific ARM Thunk implementations. The naming convention is: // Source State, TargetState, Target Requirement, ABS or PI, Range template @@ -97,7 +100,8 @@ uint32_t size() const override { return 16; } void writeTo(uint8_t *Buf) const override; }; -} // anonymous namespace + +} // end anonymous namespace // ARM Target Thunks template static uint64_t getARMThunkDestVA(const SymbolBody &S) { @@ -182,7 +186,7 @@ return Owner.OutSec->getVA() + Owner.OutSecOff + Offset; } -template Thunk::~Thunk() {} +template Thunk::~Thunk() = default; // Creates a thunk for Thumb-ARM interworking. template @@ -265,5 +269,5 @@ template class Thunk; template class Thunk; -} // namespace elf -} // namespace lld +} // end namespace elf +} // end namespace lld Index: lld/trunk/include/lld/Core/Pass.h =================================================================== --- lld/trunk/include/lld/Core/Pass.h +++ lld/trunk/include/lld/Core/Pass.h @@ -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 namespace lld { + class SimpleFile; /// Once the core linking is done (which resolves references, coalesces atoms @@ -31,16 +28,16 @@ /// 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 Index: lld/trunk/include/lld/Core/Reference.h =================================================================== --- lld/trunk/include/lld/Core/Reference.h +++ lld/trunk/include/lld/Core/Reference.h @@ -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 namespace lld { + class Atom; /// @@ -107,13 +107,13 @@ /// 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 Index: lld/trunk/lib/Core/File.cpp =================================================================== --- lld/trunk/lib/Core/File.cpp +++ lld/trunk/lib/Core/File.cpp @@ -8,12 +8,11 @@ //===----------------------------------------------------------------------===// #include "lld/Core/File.h" -#include "lld/Core/LLVM.h" #include namespace lld { -File::~File() { } +File::~File() = default; File::AtomVector File::_noDefinedAtoms; File::AtomVector File::_noUndefinedAtoms; @@ -27,4 +26,4 @@ return _lastError.getValue(); } -} // namespace lld +} // end namespace lld Index: lld/trunk/lib/Core/Reader.cpp =================================================================== --- lld/trunk/lib/Core/Reader.cpp +++ lld/trunk/lib/Core/Reader.cpp @@ -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 -#include +#include namespace lld { -YamlIOTaggedDocumentHandler::~YamlIOTaggedDocumentHandler() {} +YamlIOTaggedDocumentHandler::~YamlIOTaggedDocumentHandler() = default; void Registry::add(std::unique_ptr reader) { _readers.push_back(std::move(reader)); @@ -63,7 +64,6 @@ return false; } - void Registry::addKindTable(Reference::KindNamespace ns, Reference::KindArch arch, const KindStrings array[]) { Index: lld/trunk/lib/Core/Writer.cpp =================================================================== --- lld/trunk/lib/Core/Writer.cpp +++ lld/trunk/lib/Core/Writer.cpp @@ -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