From f49f90e97b1e4dbced1c2c4ae400e548fdae3974 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Wed, 26 Apr 2017 22:31:39 +0000 Subject: [PATCH] [MC] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301485 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/ConstantPools.h | 4 +-- include/llvm/MC/LaneBitmask.h | 9 ++++-- include/llvm/MC/MCAssembler.h | 34 ++++++++++---------- include/llvm/MC/MCContext.h | 6 +++- include/llvm/MC/MCDwarf.h | 8 ++--- include/llvm/MC/MCExpr.h | 3 +- include/llvm/MC/MCFragment.h | 4 +-- include/llvm/MC/MCInst.h | 5 +-- include/llvm/MC/MCLinkerOptimizationHint.h | 8 ++--- include/llvm/MC/MCParser/MCAsmParser.h | 6 ++-- include/llvm/MC/MCParser/MCTargetAsmParser.h | 2 +- include/llvm/MC/MCRegisterInfo.h | 8 ++--- include/llvm/MC/MCSection.h | 10 +++--- include/llvm/MC/MCStreamer.h | 3 +- include/llvm/MC/MCSubtargetInfo.h | 8 ++--- include/llvm/MC/MCSymbol.h | 4 +-- lib/MC/ELFObjectWriter.cpp | 8 ++--- lib/MC/StringTableBuilder.cpp | 2 +- lib/MC/WinCOFFObjectWriter.cpp | 15 +++++---- 19 files changed, 78 insertions(+), 69 deletions(-) diff --git a/include/llvm/MC/ConstantPools.h b/include/llvm/MC/ConstantPools.h index 643902377dd..c34211c2bd1 100644 --- a/include/llvm/MC/ConstantPools.h +++ b/include/llvm/MC/ConstantPools.h @@ -42,7 +42,7 @@ struct ConstantPoolEntry { // A class to keep track of assembler-generated constant pools that are use to // implement the ldr-pseudo. class ConstantPool { - typedef SmallVector EntryVecTy; + using EntryVecTy = SmallVector; EntryVecTy Entries; DenseMap CachedEntries; @@ -80,7 +80,7 @@ class AssemblerConstantPools { // sections in a stable order to ensure that we have print the // constant pools in a deterministic order when printing an assembly // file. - typedef MapVector ConstantPoolMapTy; + using ConstantPoolMapTy = MapVector; ConstantPoolMapTy ConstantPools; public: diff --git a/include/llvm/MC/LaneBitmask.h b/include/llvm/MC/LaneBitmask.h index 89e60928405..5ca06d1148e 100644 --- a/include/llvm/MC/LaneBitmask.h +++ b/include/llvm/MC/LaneBitmask.h @@ -1,4 +1,4 @@ -//===-- llvm/MC/LaneBitmask.h -----------------------------------*- C++ -*-===// +//===- llvm/MC/LaneBitmask.h ------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -30,14 +30,16 @@ #ifndef LLVM_MC_LANEBITMASK_H #define LLVM_MC_LANEBITMASK_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/Format.h" #include "llvm/Support/Printable.h" #include "llvm/Support/raw_ostream.h" namespace llvm { + struct LaneBitmask { // When changing the underlying type, change the format string as well. - typedef unsigned Type; + using Type = unsigned; enum : unsigned { BitWidth = 8*sizeof(Type) }; constexpr static const char *const FormatStr = "%08X"; @@ -84,6 +86,7 @@ namespace llvm { OS << format(LaneBitmask::FormatStr, LaneMask.getAsInteger()); }); } -} + +} // end namespace llvm #endif // LLVM_MC_LANEBITMASK_H diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index c29abaa03a6..185b892d962 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -60,36 +60,36 @@ class MCAssembler { friend class MCAsmLayout; public: - typedef std::vector SectionListType; - typedef std::vector SymbolDataListType; + using SectionListType = std::vector; + using SymbolDataListType = std::vector; - typedef pointee_iterator const_iterator; - typedef pointee_iterator iterator; + using const_iterator = pointee_iterator; + using iterator = pointee_iterator; - typedef pointee_iterator - const_symbol_iterator; - typedef pointee_iterator symbol_iterator; + using const_symbol_iterator = + pointee_iterator; + using symbol_iterator = pointee_iterator; - typedef iterator_range symbol_range; - typedef iterator_range const_symbol_range; + using symbol_range = iterator_range; + using const_symbol_range = iterator_range; - typedef std::vector::const_iterator - const_indirect_symbol_iterator; - typedef std::vector::iterator indirect_symbol_iterator; + using const_indirect_symbol_iterator = + std::vector::const_iterator; + using indirect_symbol_iterator = std::vector::iterator; - typedef std::vector::const_iterator - const_data_region_iterator; - typedef std::vector::iterator data_region_iterator; + using const_data_region_iterator = + std::vector::const_iterator; + using data_region_iterator = std::vector::iterator; /// MachO specific deployment target version info. // A Major version of 0 indicates that no version information was supplied // and so the corresponding load command should not be emitted. - typedef struct { + using VersionMinInfoType = struct { MCVersionMinType Kind; unsigned Major; unsigned Minor; unsigned Update; - } VersionMinInfoType; + }; private: MCContext &Context; diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index b3106936e27..9bea1963130 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -46,17 +46,19 @@ namespace llvm { class MCSectionELF; class MCSectionMachO; class MCSectionWasm; + class MCStreamer; class MCSymbol; class MCSymbolELF; class MCSymbolWasm; class SMLoc; + class SourceMgr; /// Context object for machine code objects. This class owns all of the /// sections that it creates. /// class MCContext { public: - typedef StringMap SymbolTable; + using SymbolTable = StringMap; private: /// The SourceMgr for this object, if any. @@ -223,10 +225,12 @@ namespace llvm { std::string SectionName; StringRef GroupName; unsigned UniqueID; + WasmSectionKey(StringRef SectionName, StringRef GroupName, unsigned UniqueID) : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) { } + bool operator<(const WasmSectionKey &Other) const { if (SectionName != Other.SectionName) return SectionName < Other.SectionName; diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index 0d69c2005cb..79f1b952501 100644 --- a/include/llvm/MC/MCDwarf.h +++ b/include/llvm/MC/MCDwarf.h @@ -168,10 +168,10 @@ public: MCLineDivisions[Sec].push_back(LineEntry); } - typedef std::vector MCDwarfLineEntryCollection; - typedef MCDwarfLineEntryCollection::iterator iterator; - typedef MCDwarfLineEntryCollection::const_iterator const_iterator; - typedef MapVector MCLineDivisionMap; + using MCDwarfLineEntryCollection = std::vector; + using iterator = MCDwarfLineEntryCollection::iterator; + using const_iterator = MCDwarfLineEntryCollection::const_iterator; + using MCLineDivisionMap = MapVector; private: // A collection of MCDwarfLineEntry for each section. diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h index c850abf42e2..a91a31414bd 100644 --- a/include/llvm/MC/MCExpr.h +++ b/include/llvm/MC/MCExpr.h @@ -28,7 +28,8 @@ class MCSymbol; class MCValue; class raw_ostream; class StringRef; -typedef DenseMap SectionAddrMap; + +using SectionAddrMap = DenseMap; /// \brief Base class for the full range of assembler expressions which are /// needed for parsing. diff --git a/include/llvm/MC/MCFragment.h b/include/llvm/MC/MCFragment.h index fc8257f90a9..0ca530c4510 100644 --- a/include/llvm/MC/MCFragment.h +++ b/include/llvm/MC/MCFragment.h @@ -200,8 +200,8 @@ protected: Sec) {} public: - typedef SmallVectorImpl::const_iterator const_fixup_iterator; - typedef SmallVectorImpl::iterator fixup_iterator; + using const_fixup_iterator = SmallVectorImpl::const_iterator; + using fixup_iterator = SmallVectorImpl::iterator; SmallVectorImpl &getFixups() { return Fixups; } const SmallVectorImpl &getFixups() const { return Fixups; } diff --git a/include/llvm/MC/MCInst.h b/include/llvm/MC/MCInst.h index 70227965937..9bf440ea96d 100644 --- a/include/llvm/MC/MCInst.h +++ b/include/llvm/MC/MCInst.h @@ -176,8 +176,9 @@ public: void addOperand(const MCOperand &Op) { Operands.push_back(Op); } - typedef SmallVectorImpl::iterator iterator; - typedef SmallVectorImpl::const_iterator const_iterator; + using iterator = SmallVectorImpl::iterator; + using const_iterator = SmallVectorImpl::const_iterator; + void clear() { Operands.clear(); } void erase(iterator I) { Operands.erase(I); } size_t size() const { return Operands.size(); } diff --git a/include/llvm/MC/MCLinkerOptimizationHint.h b/include/llvm/MC/MCLinkerOptimizationHint.h index 0c3525bbeda..f0fd07f43cf 100644 --- a/include/llvm/MC/MCLinkerOptimizationHint.h +++ b/include/llvm/MC/MCLinkerOptimizationHint.h @@ -111,7 +111,7 @@ class MCLOHDirective { const MCAsmLayout &Layout) const; public: - typedef SmallVectorImpl LOHArgs; + using LOHArgs = SmallVectorImpl; MCLOHDirective(MCLOHType Kind, const LOHArgs &Args) : Kind(Kind), Args(Args.begin(), Args.end()) { @@ -140,7 +140,7 @@ class MCLOHContainer { SmallVector Directives; public: - typedef SmallVectorImpl LOHDirectives; + using LOHDirectives = SmallVectorImpl; MCLOHContainer() = default; @@ -179,8 +179,8 @@ public: }; // Add types for specialized template using MCSymbol. -typedef MCLOHDirective::LOHArgs MCLOHArgs; -typedef MCLOHContainer::LOHDirectives MCLOHDirectives; +using MCLOHArgs = MCLOHDirective::LOHArgs; +using MCLOHDirectives = MCLOHContainer::LOHDirectives; } // end namespace llvm diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h index 6763374185e..75d45f490bd 100644 --- a/include/llvm/MC/MCParser/MCAsmParser.h +++ b/include/llvm/MC/MCParser/MCAsmParser.h @@ -67,9 +67,9 @@ public: /// assembly parsers. class MCAsmParser { public: - typedef bool (*DirectiveHandler)(MCAsmParserExtension*, StringRef, SMLoc); - typedef std::pair - ExtensionDirectiveHandler; + using DirectiveHandler = bool (*)(MCAsmParserExtension*, StringRef, SMLoc); + using ExtensionDirectiveHandler = + std::pair; struct MCPendingError { SMLoc Loc; diff --git a/include/llvm/MC/MCParser/MCTargetAsmParser.h b/include/llvm/MC/MCParser/MCTargetAsmParser.h index c81a7624011..b8d3180cd49 100644 --- a/include/llvm/MC/MCParser/MCTargetAsmParser.h +++ b/include/llvm/MC/MCParser/MCTargetAsmParser.h @@ -27,7 +27,7 @@ class MCStreamer; class MCSubtargetInfo; template class SmallVectorImpl; -typedef SmallVectorImpl> OperandVector; +using OperandVector = SmallVectorImpl>; enum AsmRewriteKind { AOK_Delete = 0, // Rewrite should be ignored. diff --git a/include/llvm/MC/MCRegisterInfo.h b/include/llvm/MC/MCRegisterInfo.h index 015d0b96d9f..de98abe0dc4 100644 --- a/include/llvm/MC/MCRegisterInfo.h +++ b/include/llvm/MC/MCRegisterInfo.h @@ -27,13 +27,13 @@ namespace llvm { /// An unsigned integer type large enough to represent all physical registers, /// but not necessarily virtual registers. -typedef uint16_t MCPhysReg; +using MCPhysReg = uint16_t; /// MCRegisterClass - Base class of TargetRegisterClass. class MCRegisterClass { public: - typedef const MCPhysReg* iterator; - typedef const MCPhysReg* const_iterator; + using iterator = const MCPhysReg*; + using const_iterator = const MCPhysReg*; const iterator RegsBegin; const uint8_t *const RegSet; @@ -134,7 +134,7 @@ struct MCRegisterDesc { /// class MCRegisterInfo { public: - typedef const MCRegisterClass *regclass_iterator; + using regclass_iterator = const MCRegisterClass *; /// DwarfLLVMRegPair - Emitted by tablegen so Dwarf<->LLVM reg mappings can be /// performed with a binary search. diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h index 2974d8f1b80..7bfffbcdb7c 100644 --- a/include/llvm/MC/MCSection.h +++ b/include/llvm/MC/MCSection.h @@ -47,13 +47,13 @@ public: BundleLockedAlignToEnd }; - typedef iplist FragmentListType; + using FragmentListType = iplist; - typedef FragmentListType::const_iterator const_iterator; - typedef FragmentListType::iterator iterator; + using const_iterator = FragmentListType::const_iterator; + using iterator = FragmentListType::iterator; - typedef FragmentListType::const_reverse_iterator const_reverse_iterator; - typedef FragmentListType::reverse_iterator reverse_iterator; + using const_reverse_iterator = FragmentListType::const_reverse_iterator; + using reverse_iterator = FragmentListType::reverse_iterator; private: MCSymbol *Begin; diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index eb301031ba3..5390e794242 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -44,12 +44,11 @@ class MCInstPrinter; class MCSection; class MCStreamer; class MCSymbolRefExpr; -class MCSymbolWasm; class MCSubtargetInfo; class raw_ostream; class Twine; -typedef std::pair MCSectionSubPair; +using MCSectionSubPair = std::pair; /// Target specific streamer interface. This is used so that targets can /// implement support for target specific assembly directives. diff --git a/include/llvm/MC/MCSubtargetInfo.h b/include/llvm/MC/MCSubtargetInfo.h index bb16463588c..d1d5d070bf5 100644 --- a/include/llvm/MC/MCSubtargetInfo.h +++ b/include/llvm/MC/MCSubtargetInfo.h @@ -26,6 +26,7 @@ #include namespace llvm { + class MachineInstr; class MCInst; @@ -63,8 +64,7 @@ public: MCSubtargetInfo() = delete; MCSubtargetInfo &operator=(const MCSubtargetInfo &) = delete; MCSubtargetInfo &operator=(MCSubtargetInfo &&) = delete; - - virtual ~MCSubtargetInfo() {} + virtual ~MCSubtargetInfo() = default; /// getTargetTriple - Return the target triple string. const Triple &getTargetTriple() const { return TargetTriple; } @@ -178,11 +178,11 @@ public: /// Returns string representation of scheduler comment virtual std::string getSchedInfoStr(const MachineInstr &MI) const { - return std::string(); + return {}; } virtual std::string getSchedInfoStr(MCInst const &MCI) const { - return std::string(); + return {}; } }; diff --git a/include/llvm/MC/MCSymbol.h b/include/llvm/MC/MCSymbol.h index e8432afd862..9b1cc6e7d7e 100644 --- a/include/llvm/MC/MCSymbol.h +++ b/include/llvm/MC/MCSymbol.h @@ -145,10 +145,10 @@ protected: /// MCSymbol contains a uint64_t so is probably aligned to 8. On a 32-bit /// system, the name is a pointer so isn't going to satisfy the 8 byte /// alignment of uint64_t. Account for that here. - typedef union { + using NameEntryStorageTy = union { const StringMapEntry *NameEntry; uint64_t AlignmentPadding; - } NameEntryStorageTy; + }; MCSymbol(SymbolKind Kind, const StringMapEntry *Name, bool isTemporary) : IsTemporary(isTemporary), IsRedefinable(false), IsUsed(false), diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index ee9c25cda94..e86db933af3 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -63,7 +63,7 @@ using namespace llvm; namespace { -typedef DenseMap SectionIndexMapTy; +using SectionIndexMapTy = DenseMap; class ELFObjectWriter; @@ -194,8 +194,8 @@ public: ELFSymbolData &MSD, const MCAsmLayout &Layout); // Start and end offset of each section - typedef std::map> - SectionOffsetsTy; + using SectionOffsetsTy = + std::map>; bool shouldRelocateWithSymbol(const MCAssembler &Asm, const MCSymbolRefExpr *RefA, @@ -208,7 +208,7 @@ public: uint64_t &FixedValue) override; // Map from a signature symbol to the group section index - typedef DenseMap RevGroupMapTy; + using RevGroupMapTy = DenseMap; /// Compute the symbol table data /// diff --git a/lib/MC/StringTableBuilder.cpp b/lib/MC/StringTableBuilder.cpp index fbd7ba60bc9..a0fb33846fc 100644 --- a/lib/MC/StringTableBuilder.cpp +++ b/lib/MC/StringTableBuilder.cpp @@ -58,7 +58,7 @@ void StringTableBuilder::write(raw_ostream &OS) const { OS << Data; } -typedef std::pair StringPair; +using StringPair = std::pair; void StringTableBuilder::write(uint8_t *Buf) const { assert(isFinalized()); diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index da8fe73f823..e99a548ac00 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -38,6 +38,7 @@ #include "llvm/Support/JamCRC.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" +#include #include #include #include @@ -54,7 +55,7 @@ using llvm::support::endian::write32le; namespace { -typedef SmallString name; +using name = SmallString; enum AuxiliaryType { ATFunctionDefinition, @@ -75,7 +76,7 @@ class COFFSymbol { public: COFF::symbol Data = {}; - typedef SmallVector AuxiliarySymbols; + using AuxiliarySymbols = SmallVector; name Name; int Index; @@ -107,7 +108,7 @@ struct COFFRelocation { static size_t size() { return COFF::RelocationSize; } }; -typedef std::vector relocations; +using relocations = std::vector; class COFFSection { public: @@ -124,11 +125,11 @@ public: class WinCOFFObjectWriter : public MCObjectWriter { public: - typedef std::vector> symbols; - typedef std::vector> sections; + using symbols = std::vector>; + using sections = std::vector>; - typedef DenseMap symbol_map; - typedef DenseMap section_map; + using symbol_map = DenseMap; + using section_map = DenseMap; std::unique_ptr TargetObjectWriter; -- 2.50.1