From 68b9f45feee290a0ffecf6002f2cad926ab7fd69 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 1 Apr 2019 00:11:24 +0000 Subject: [PATCH] Replace `typedef A B` with `using B = A`. NFC. I did this using Perl. Differential Revision: https://reviews.llvm.org/D60003 llvm-svn: 357372 --- lld/COFF/Driver.cpp | 2 +- lld/COFF/MapFile.cpp | 4 ++-- lld/ELF/CallGraphSort.cpp | 4 ++-- lld/ELF/InputFiles.h | 36 ++++++++++++++++++------------------ lld/ELF/InputSection.cpp | 6 +++--- lld/ELF/LinkerScript.h | 2 +- lld/ELF/MapFile.cpp | 2 +- lld/ELF/OutputSections.cpp | 4 ++-- lld/ELF/Relocations.cpp | 4 ++-- lld/ELF/Relocations.h | 2 +- lld/ELF/SyntheticSections.cpp | 6 +++--- lld/ELF/SyntheticSections.h | 38 +++++++++++++++++++------------------- lld/ELF/Writer.cpp | 6 +++--- 13 files changed, 58 insertions(+), 58 deletions(-) diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 0ffe059..6acf277 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -96,7 +96,7 @@ static std::string getOutputPath(StringRef Path) { // FIXME: We could open the file in createFutureForFile and avoid needing to // return an error here, but for the moment that would cost us a file descriptor // (a limited resource on Windows) for the duration that the future is pending. -typedef std::pair, std::error_code> MBErrPair; +using MBErrPair = std::pair, std::error_code>; // Create a std::future that opens and maps a file using the best strategy for // the host platform. diff --git a/lld/COFF/MapFile.cpp b/lld/COFF/MapFile.cpp index 5e1a3d0..fc5af18 100644 --- a/lld/COFF/MapFile.cpp +++ b/lld/COFF/MapFile.cpp @@ -32,8 +32,8 @@ using namespace llvm::object; using namespace lld; using namespace lld::coff; -typedef DenseMap> - SymbolMapTy; +using SymbolMapTy = + DenseMap>; static const std::string Indent8 = " "; // 8 spaces static const std::string Indent16 = " "; // 16 spaces diff --git a/lld/ELF/CallGraphSort.cpp b/lld/ELF/CallGraphSort.cpp index 8550177..10fc6bf 100644 --- a/lld/ELF/CallGraphSort.cpp +++ b/lld/ELF/CallGraphSort.cpp @@ -92,8 +92,8 @@ constexpr int MAX_DENSITY_DEGRADATION = 8; constexpr uint64_t MAX_CLUSTER_SIZE = 1024 * 1024; } // end anonymous namespace -typedef std::pair - SectionPair; +using SectionPair = + std::pair; // Take the edge list in Config->CallGraphProfile, resolve symbol names to // Symbols, and generate a graph between InputSections with the provided diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index b786042..fe8f0f8 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -147,10 +147,10 @@ private: template class ELFFileBase : public InputFile { public: - typedef typename ELFT::Shdr Elf_Shdr; - typedef typename ELFT::Sym Elf_Sym; - typedef typename ELFT::Word Elf_Word; - typedef typename ELFT::SymRange Elf_Sym_Range; + using Elf_Shdr = typename ELFT::Shdr; + using Elf_Sym = typename ELFT::Sym; + using Elf_Word = typename ELFT::Word; + using Elf_Sym_Range = typename ELFT::SymRange; ELFFileBase(Kind K, MemoryBufferRef M); static bool classof(const InputFile *F) { return F->isElf(); } @@ -176,13 +176,13 @@ protected: // .o file. template class ObjFile : public ELFFileBase { - typedef ELFFileBase Base; - typedef typename ELFT::Rel Elf_Rel; - typedef typename ELFT::Rela Elf_Rela; - typedef typename ELFT::Sym Elf_Sym; - typedef typename ELFT::Shdr Elf_Shdr; - typedef typename ELFT::Word Elf_Word; - typedef typename ELFT::CGProfile Elf_CGProfile; + using Base = ELFFileBase; + using Elf_Rel = typename ELFT::Rel; + using Elf_Rela = typename ELFT::Rela; + using Elf_Sym = typename ELFT::Sym; + using Elf_Shdr = typename ELFT::Shdr; + using Elf_Word = typename ELFT::Word; + using Elf_CGProfile = typename ELFT::CGProfile; StringRef getShtGroupSignature(ArrayRef Sections, const Elf_Shdr &Sec); @@ -321,13 +321,13 @@ public: // .so file. template class SharedFile : public ELFFileBase { - typedef ELFFileBase Base; - typedef typename ELFT::Dyn Elf_Dyn; - typedef typename ELFT::Shdr Elf_Shdr; - typedef typename ELFT::Sym Elf_Sym; - typedef typename ELFT::SymRange Elf_Sym_Range; - typedef typename ELFT::Verdef Elf_Verdef; - typedef typename ELFT::Versym Elf_Versym; + using Base = ELFFileBase; + using Elf_Dyn = typename ELFT::Dyn; + using Elf_Shdr = typename ELFT::Shdr; + using Elf_Sym = typename ELFT::Sym; + using Elf_Sym_Range = typename ELFT::SymRange; + using Elf_Verdef = typename ELFT::Verdef; + using Elf_Versym = typename ELFT::Versym; const Elf_Shdr *VersymSec = nullptr; const Elf_Shdr *VerdefSec = nullptr; diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 88eccbe..8acaa2c 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -210,8 +210,8 @@ OutputSection *SectionBase::getOutputSection() { // by zlib-compressed data. This function parses a header to initialize // `UncompressedSize` member and remove the header from `RawData`. void InputSectionBase::parseCompressedHeader() { - typedef typename ELF64LE::Chdr Chdr64; - typedef typename ELF32LE::Chdr Chdr32; + using Chdr64 = typename ELF64LE::Chdr; + using Chdr32 = typename ELF32LE::Chdr; // Old-style header if (Name.startswith(".zdebug")) { @@ -380,7 +380,7 @@ OutputSection *InputSection::getParent() const { // Copy SHT_GROUP section contents. Used only for the -r option. template void InputSection::copyShtGroup(uint8_t *Buf) { // ELFT::Word is the 32-bit integral type in the target endianness. - typedef typename ELFT::Word u32; + using u32 = typename ELFT::Word; ArrayRef From = getDataAs(); auto *To = reinterpret_cast(Buf); diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index b993810..e5f464f 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -67,7 +67,7 @@ struct ExprValue { // This represents an expression in the linker script. // ScriptParser::readExpr reads an expression and returns an Expr. // Later, we evaluate the expression by calling the function. -typedef std::function Expr; +using Expr = std::function; // This enum is used to implement linker script SECTIONS command. // https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS diff --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp index cc5b31d..d9ff3e7 100644 --- a/lld/ELF/MapFile.cpp +++ b/lld/ELF/MapFile.cpp @@ -37,7 +37,7 @@ using namespace llvm::object; using namespace lld; using namespace lld::elf; -typedef DenseMap> SymbolMapTy; +using SymbolMapTy = DenseMap>; static const std::string Indent8 = " "; // 8 spaces static const std::string Indent16 = " "; // 16 spaces diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 4cb5a3c..6a80b5b1 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -138,7 +138,7 @@ void OutputSection::addSection(InputSection *IS) { static void sortByOrder(MutableArrayRef In, llvm::function_ref Order) { - typedef std::pair Pair; + using Pair = std::pair; auto Comp = [](const Pair &A, const Pair &B) { return A.first < B.first; }; std::vector V; @@ -179,7 +179,7 @@ static void fill(uint8_t *Buf, size_t Size, // Compress section contents if this section contains debug info. template void OutputSection::maybeCompress() { - typedef typename ELFT::Chdr Elf_Chdr; + using Elf_Chdr = typename ELFT::Chdr; // Compress only DWARF debug sections. if (!Config->CompressDebugSections || (Flags & SHF_ALLOC) || diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index ada625c..7935f63 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -479,7 +479,7 @@ static RelExpr fromPlt(RelExpr Expr) { // Returns true if a given shared symbol is in a read-only segment in a DSO. template static bool isReadOnly(SharedSymbol &SS) { - typedef typename ELFT::Phdr Elf_Phdr; + using Elf_Phdr = typename ELFT::Phdr; // Determine if the symbol is read-only by scanning the DSO's program headers. const SharedFile &File = SS.getFile(); @@ -498,7 +498,7 @@ template static bool isReadOnly(SharedSymbol &SS) { // Otherwise, they would refer to different places at runtime. template static SmallSet getSymbolsAt(SharedSymbol &SS) { - typedef typename ELFT::Sym Elf_Sym; + using Elf_Sym = typename ELFT::Sym; SharedFile &File = SS.getFile(); diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h index 230fac0..a3edea5 100644 --- a/lld/ELF/Relocations.h +++ b/lld/ELF/Relocations.h @@ -23,7 +23,7 @@ class OutputSection; class SectionBase; // Represents a relocation type, such as R_X86_64_PC32 or R_ARM_THM_CALL. -typedef uint32_t RelType; +using RelType = uint32_t; // List of target-independent relocation types. Relocations read // from files are converted to these types so that the main code diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 142caaa..80be0d9 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2474,8 +2474,8 @@ readPubNamesAndTypes(const LLDDwarfObj &Obj, static std::vector createSymbols(ArrayRef> NameAttrs, const std::vector &Chunks) { - typedef GdbIndexSection::GdbSymbol GdbSymbol; - typedef GdbIndexSection::NameAttrEntry NameAttrEntry; + using GdbSymbol = GdbIndexSection::GdbSymbol; + using NameAttrEntry = GdbIndexSection::NameAttrEntry; // For each chunk, compute the number of compilation units preceding it. uint32_t CuIdx = 0; @@ -2669,7 +2669,7 @@ void EhFrameHeader::writeTo(uint8_t *Buf) { // It is sorted by PC. void EhFrameHeader::write() { uint8_t *Buf = Out::BufferStart + getParent()->Offset + OutSecOff; - typedef EhFrameSection::FdeData FdeData; + using FdeData = EhFrameSection::FdeData; std::vector Fdes = In.EhFrame->getFdeData(); diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index 7923435..825502b 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -308,7 +308,7 @@ private: uint64_t Size = 0; // Symbol and addend. - typedef std::pair GotEntry; + using GotEntry = std::pair; struct FileGot { InputFile *File = nullptr; @@ -443,12 +443,12 @@ private: }; template class DynamicSection final : public SyntheticSection { - typedef typename ELFT::Dyn Elf_Dyn; - typedef typename ELFT::Rel Elf_Rel; - typedef typename ELFT::Rela Elf_Rela; - typedef typename ELFT::Relr Elf_Relr; - typedef typename ELFT::Shdr Elf_Shdr; - typedef typename ELFT::Sym Elf_Sym; + using Elf_Dyn = typename ELFT::Dyn; + using Elf_Rel = typename ELFT::Rel; + using Elf_Rela = typename ELFT::Rela; + using Elf_Relr = typename ELFT::Relr; + using Elf_Shdr = typename ELFT::Shdr; + using Elf_Sym = typename ELFT::Sym; // finalizeContents() fills this vector with the section contents. std::vector>> Entries; @@ -496,8 +496,8 @@ protected: template class RelocationSection final : public RelocationBaseSection { - typedef typename ELFT::Rel Elf_Rel; - typedef typename ELFT::Rela Elf_Rela; + using Elf_Rel = typename ELFT::Rel; + using Elf_Rela = typename ELFT::Rela; public: RelocationSection(StringRef Name, bool Sort); @@ -509,8 +509,8 @@ private: template class AndroidPackedRelocationSection final : public RelocationBaseSection { - typedef typename ELFT::Rel Elf_Rel; - typedef typename ELFT::Rela Elf_Rela; + using Elf_Rel = typename ELFT::Rel; + using Elf_Rela = typename ELFT::Rela; public: AndroidPackedRelocationSection(StringRef Name); @@ -544,7 +544,7 @@ public: // https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg // For more details, see the comment in RelrSection::updateAllocSize(). template class RelrSection final : public RelrBaseSection { - typedef typename ELFT::Relr Elf_Relr; + using Elf_Relr = typename ELFT::Relr; public: RelrSection(); @@ -589,7 +589,7 @@ protected: template class SymbolTableSection final : public SymbolTableBaseSection { - typedef typename ELFT::Sym Elf_Sym; + using Elf_Sym = typename ELFT::Sym; public: SymbolTableSection(StringTableSection &StrTabSec); @@ -804,8 +804,8 @@ public: // mapping from version identifiers to version names. template class VersionNeedSection final : public VersionNeedBaseSection { - typedef typename ELFT::Verneed Elf_Verneed; - typedef typename ELFT::Vernaux Elf_Vernaux; + using Elf_Verneed = typename ELFT::Verneed; + using Elf_Vernaux = typename ELFT::Vernaux; // A vector of shared files that need Elf_Verneed data structures and the // string table offsets of their sonames. @@ -880,7 +880,7 @@ private: // .MIPS.abiflags section. template class MipsAbiFlagsSection final : public SyntheticSection { - typedef llvm::object::Elf_Mips_ABIFlags Elf_Mips_ABIFlags; + using Elf_Mips_ABIFlags = llvm::object::Elf_Mips_ABIFlags; public: static MipsAbiFlagsSection *create(); @@ -895,8 +895,8 @@ private: // .MIPS.options section. template class MipsOptionsSection final : public SyntheticSection { - typedef llvm::object::Elf_Mips_Options Elf_Mips_Options; - typedef llvm::object::Elf_Mips_RegInfo Elf_Mips_RegInfo; + using Elf_Mips_Options = llvm::object::Elf_Mips_Options; + using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo; public: static MipsOptionsSection *create(); @@ -914,7 +914,7 @@ private: // MIPS .reginfo section. template class MipsReginfoSection final : public SyntheticSection { - typedef llvm::object::Elf_Mips_RegInfo Elf_Mips_RegInfo; + using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo; public: static MipsReginfoSection *create(); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 16b9a22..71736f1 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -40,9 +40,9 @@ namespace { template class Writer { public: Writer() : Buffer(errorHandler().OutputBuffer) {} - typedef typename ELFT::Shdr Elf_Shdr; - typedef typename ELFT::Ehdr Elf_Ehdr; - typedef typename ELFT::Phdr Elf_Phdr; + using Elf_Shdr = typename ELFT::Shdr; + using Elf_Ehdr = typename ELFT::Ehdr; + using Elf_Phdr = typename ELFT::Phdr; void run(); -- 2.7.4