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

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

llvm-svn: 286030
This commit is contained in:
Eugene Zelenko 2016-11-05 01:00:56 +00:00
parent fbc9ff244c
commit 22886a2853
9 changed files with 94 additions and 46 deletions

View File

@ -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> createLTO() {
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::compile() {
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) {

View File

@ -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 isDiscarded(InputSectionBase<ELFT> *S) {
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(OutputSectionFactory<ELFT> &Factory,
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(std::vector<PhdrEntry<ELFT>> &Phdrs) {
// Continue from where we found it.
CmdIndex = (Pos - Opt.Commands.begin()) + 1;
continue;
}
// Assign addresses as instructed by linker script SECTIONS sub-commands.

View File

@ -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, ReadOnly, ReadWrite };
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 : BaseCommand {
// 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 final : public LinkerScriptBase {
public:
LinkerScript();
~LinkerScript();
void processCommands(OutputSectionFactory<ELFT> &Factory);
void createSections(OutputSectionFactory<ELFT> &Factory);
void adjustSectionsBeforeSorting();
@ -263,7 +279,7 @@ template <class ELFT> LinkerScript<ELFT> *Script<ELFT>::X;
extern LinkerScriptBase *ScriptBase;
} // namespace elf
} // namespace lld
} // end namespace elf
} // end namespace lld
#endif
#endif // LLD_ELF_LINKER_SCRIPT_H

View File

@ -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::uint Thunk<ELFT>::getVA() const {
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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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::yaml::IO &io,
return false;
}
void Registry::addKindTable(Reference::KindNamespace ns,
Reference::KindArch arch,
const KindStrings array[]) {

View File

@ -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