From e7553e4eacf4eed17c5cdac3c552408a245ff892 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 31 Aug 2016 13:28:33 +0000 Subject: [PATCH] Delete unnecessary template. llvm-svn: 280237 --- lld/ELF/InputSection.cpp | 13 ++++++------- lld/ELF/InputSection.h | 4 ++-- lld/ELF/LinkerScript.h | 2 +- lld/ELF/SymbolTable.cpp | 16 +++++++--------- lld/ELF/Symbols.cpp | 15 ++++----------- lld/ELF/Symbols.h | 11 +++++------ lld/ELF/Writer.cpp | 7 +++---- 7 files changed, 28 insertions(+), 40 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index a69904439197..774d3f0f2dd9 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -698,8 +698,7 @@ bool MipsAbiFlagsInputSection::classof(const InputSectionBase *S) { } template -CommonInputSection::CommonInputSection( - std::vector *> Syms) +CommonInputSection::CommonInputSection(std::vector Syms) : InputSection(nullptr, &Hdr) { Hdr.sh_size = 0; Hdr.sh_type = SHT_NOBITS; @@ -707,12 +706,12 @@ CommonInputSection::CommonInputSection( this->Live = true; // Sort the common symbols by alignment as an heuristic to pack them better. - std::stable_sort(Syms.begin(), Syms.end(), [](const DefinedCommon *A, - const DefinedCommon *B) { - return A->Alignment > B->Alignment; - }); + std::stable_sort(Syms.begin(), Syms.end(), + [](const DefinedCommon *A, const DefinedCommon *B) { + return A->Alignment > B->Alignment; + }); - for (DefinedCommon *Sym : Syms) { + for (DefinedCommon *Sym : Syms) { this->Alignment = std::max(this->Alignment, Sym->Alignment); Hdr.sh_size = alignTo(Hdr.sh_size, Sym->Alignment); diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 28c621b1609e..a12b5919b6eb 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -21,11 +21,11 @@ namespace lld { namespace elf { +class DefinedCommon; class SymbolBody; template class ICF; template class DefinedRegular; -template class DefinedCommon; template class ObjectFile; template class OutputSection; template class OutputSectionBase; @@ -287,7 +287,7 @@ template class CommonInputSection : public InputSection { typedef typename ELFT::uint uintX_t; public: - CommonInputSection(std::vector *> Syms); + CommonInputSection(std::vector Syms); // The singleton instance of this class. static CommonInputSection *X; diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index b31616c9c26d..f08bd0762b5f 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -20,12 +20,12 @@ namespace lld { namespace elf { +class DefinedCommon; class ScriptParser; class SymbolBody; template class InputSectionBase; template class OutputSectionBase; template class OutputSectionFactory; -template class DefinedCommon; template class LayoutInputSection; typedef std::function Expr; diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 0aacb04aa95d..e99e5077d7ed 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -326,7 +326,6 @@ static int compareDefined(Symbol *S, bool WasInserted, uint8_t Binding) { // We have a new non-common defined symbol with the specified binding. Return 1 // if the new symbol should win, -1 if the new symbol should lose, or 0 if there // is a conflict. If the new symbol wins, also update the binding. -template static int compareDefinedNonCommon(Symbol *S, bool WasInserted, uint8_t Binding) { if (int Cmp = compareDefined(S, WasInserted, Binding)) { @@ -334,7 +333,7 @@ static int compareDefinedNonCommon(Symbol *S, bool WasInserted, S->Binding = Binding; return Cmp; } - if (isa>(S->body())) { + if (isa(S->body())) { // Non-common symbols take precedence over common symbols. if (Config->WarnCommon) warning("common " + S->body()->getName() + " is overridden"); @@ -356,10 +355,9 @@ Symbol *SymbolTable::addCommon(StringRef N, uint64_t Size, int Cmp = compareDefined(S, WasInserted, Binding); if (Cmp > 0) { S->Binding = Binding; - replaceBody>(S, N, Size, Alignment, StOther, Type, - File); + replaceBody(S, N, Size, Alignment, StOther, Type, File); } else if (Cmp == 0) { - auto *C = dyn_cast>(S->body()); + auto *C = dyn_cast(S->body()); if (!C) { // Non-common symbols take precedence over common symbols. if (Config->WarnCommon) @@ -395,7 +393,7 @@ Symbol *SymbolTable::addRegular(StringRef Name, const Elf_Sym &Sym, Name, Sym.getType(), Sym.getVisibility(), /*CanOmitFromDynSym*/ false, /*HasUnnamedAddr*/ false, /*IsUsedInRegularObj*/ true, Section ? Section->getFile() : nullptr); - int Cmp = compareDefinedNonCommon(S, WasInserted, Sym.getBinding()); + int Cmp = compareDefinedNonCommon(S, WasInserted, Sym.getBinding()); if (Cmp > 0) replaceBody>(S, Name, Sym, Section); else if (Cmp == 0) @@ -411,7 +409,7 @@ Symbol *SymbolTable::addRegular(StringRef Name, uint8_t Binding, std::tie(S, WasInserted) = insert(Name, STT_NOTYPE, StOther & 3, /*CanOmitFromDynSym*/ false, /*HasUnnamedAddr*/ false, /*IsUsedInRegularObj*/ true, nullptr); - int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); + int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); if (Cmp > 0) replaceBody>(S, Name, StOther); else if (Cmp == 0) @@ -429,7 +427,7 @@ Symbol *SymbolTable::addSynthetic(StringRef N, /*CanOmitFromDynSym*/ false, /*HasUnnamedAddr*/ false, /*IsUsedInRegularObj*/ true, nullptr); - int Cmp = compareDefinedNonCommon(S, WasInserted, STB_GLOBAL); + int Cmp = compareDefinedNonCommon(S, WasInserted, STB_GLOBAL); if (Cmp > 0) replaceBody>(S, N, Value, Section); else if (Cmp == 0) @@ -469,7 +467,7 @@ Symbol *SymbolTable::addBitcode(StringRef Name, uint8_t Binding, std::tie(S, WasInserted) = insert(Name, Type, StOther & 3, CanOmitFromDynSym, HasUnnamedAddr, /*IsUsedInRegularObj*/ false, F); - int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); + int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); if (Cmp > 0) replaceBody>(S, Name, StOther, Type, F); else if (Cmp == 0) diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 7699cb2b520f..88d3620613f6 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -66,7 +66,7 @@ static typename ELFT::uint getSymVA(const SymbolBody &Body, case SymbolBody::DefinedCommonKind: return CommonInputSection::X->OutSec->getVA() + CommonInputSection::X->OutSecOff + - cast>(Body).Offset; + cast(Body).Offset; case SymbolBody::SharedKind: { auto &SS = cast>(Body); if (!SS.NeedsCopyOrPltAddr) @@ -175,7 +175,7 @@ template typename ELFT::uint SymbolBody::getThunkVA() const { } template typename ELFT::uint SymbolBody::getSize() const { - if (const auto *C = dyn_cast>(this)) + if (const auto *C = dyn_cast(this)) return C->Size; if (const auto *DR = dyn_cast>(this)) return DR->Size; @@ -208,10 +208,8 @@ DefinedSynthetic::DefinedSynthetic(StringRef N, uintX_t Value, : Defined(SymbolBody::DefinedSyntheticKind, N, STV_HIDDEN, 0 /* Type */), Value(Value), Section(Section) {} -template -DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, - uint64_t Alignment, uint8_t StOther, - uint8_t Type, InputFile *File) +DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment, + uint8_t StOther, uint8_t Type, InputFile *File) : Defined(SymbolBody::DefinedCommonKind, N, StOther, Type), Alignment(Alignment), Size(Size) { this->File = File; @@ -321,8 +319,3 @@ template class elf::DefinedSynthetic; template class elf::DefinedSynthetic; template class elf::DefinedSynthetic; template class elf::DefinedSynthetic; - -template class elf::DefinedCommon; -template class elf::DefinedCommon; -template class elf::DefinedCommon; -template class elf::DefinedCommon; diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index abbfa26cc13a..0526865a00c0 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -158,7 +158,7 @@ public: static bool classof(const SymbolBody *S) { return S->isDefined(); } }; -template class DefinedCommon : public Defined { +class DefinedCommon : public Defined { public: DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment, uint8_t StOther, uint8_t Type, InputFile *File); @@ -436,11 +436,10 @@ struct Symbol { // large and aligned enough to store any derived class of SymbolBody. We // assume that the size and alignment of ELF64LE symbols is sufficient for any // ELFT, and we verify this with the static_asserts in replaceBody. - llvm::AlignedCharArrayUnion, - DefinedRegular, - DefinedSynthetic, - Undefined, SharedSymbol, - LazyArchive, LazyObject> + llvm::AlignedCharArrayUnion< + DefinedCommon, DefinedRegular, + DefinedSynthetic, Undefined, + SharedSymbol, LazyArchive, LazyObject> Body; SymbolBody *body() { return reinterpret_cast(Body.buffer); } diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 11c15a3990ff..a3c59d45261a 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -229,11 +229,10 @@ template void elf::writeResult() { Out::Pool.clear(); } -template -static std::vector *> getCommonSymbols() { - std::vector *> V; +template static std::vector getCommonSymbols() { + std::vector V; for (Symbol *S : Symtab::X->getSymbols()) - if (auto *B = dyn_cast>(S->body())) + if (auto *B = dyn_cast(S->body())) V.push_back(B); return V; }