From 403aa6c77c92828c5608a005c29a6e7a4837ad52 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Fri, 23 Jun 2017 21:57:40 +0000 Subject: [PATCH] [DebugInfo] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC). llvm-svn: 306169 --- include/llvm/DebugInfo/DIContext.h | 5 ++-- .../DWARF/DWARFAbbreviationDeclaration.h | 7 ++--- .../DebugInfo/DWARF/DWARFAcceleratorTable.h | 5 ++-- include/llvm/DebugInfo/DWARF/DWARFContext.h | 22 ++++++++------- .../llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h | 10 ++++--- .../DebugInfo/DWARF/DWARFDebugArangeSet.h | 4 +-- .../llvm/DebugInfo/DWARF/DWARFDebugAranges.h | 4 +-- include/llvm/DebugInfo/DWARF/DWARFDebugLine.h | 20 ++++++++------ include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h | 4 +-- .../llvm/DebugInfo/DWARF/DWARFDebugMacro.h | 2 +- .../DebugInfo/DWARF/DWARFDebugRangeList.h | 4 +-- include/llvm/DebugInfo/DWARF/DWARFRelocMap.h | 3 +-- include/llvm/DebugInfo/DWARF/DWARFUnit.h | 14 +++++----- include/llvm/DebugInfo/MSF/MSFBuilder.h | 13 +++++---- include/llvm/DebugInfo/MSF/MSFCommon.h | 18 +++++++------ .../llvm/DebugInfo/MSF/MappedBlockStream.h | 20 +++++++------- .../DebugInfo/Symbolize/SymbolizableModule.h | 16 +++++------ include/llvm/DebugInfo/Symbolize/Symbolize.h | 21 ++++++++++----- lib/DebugInfo/DWARF/DWARFContext.cpp | 15 +++++------ lib/DebugInfo/DWARF/DWARFDebugFrame.cpp | 3 +-- lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 12 ++++++--- lib/DebugInfo/DWARF/DWARFUnit.cpp | 10 +++---- lib/DebugInfo/MSF/MSFBuilder.cpp | 27 ++++++++++++------- lib/DebugInfo/MSF/MSFCommon.cpp | 6 ++++- lib/DebugInfo/MSF/MappedBlockStream.cpp | 23 +++++++++++----- 25 files changed, 165 insertions(+), 123 deletions(-) diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index 2e82a774cc2..4126e245ff1 100644 --- a/include/llvm/DebugInfo/DIContext.h +++ b/include/llvm/DebugInfo/DIContext.h @@ -57,7 +57,7 @@ struct DILineInfo { } }; -typedef SmallVector, 16> DILineInfoTable; +using DILineInfoTable = SmallVector, 16>; /// DIInliningInfo - a format-neutral container for inlined code description. class DIInliningInfo { @@ -102,7 +102,7 @@ enum class DINameKind { None, ShortName, LinkageName }; /// should be filled with data. struct DILineInfoSpecifier { enum class FileLineInfoKind { None, Default, AbsoluteFilePath }; - typedef DINameKind FunctionNameKind; + using FunctionNameKind = DINameKind; FileLineInfoKind FLIKind; FunctionNameKind FNKind; @@ -174,6 +174,7 @@ public: // No verifier? Just say things went well. return true; } + virtual DILineInfo getLineInfoForAddress(uint64_t Address, DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0; virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address, diff --git a/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h index e363cff1580..190a69b7573 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h +++ b/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h @@ -33,6 +33,7 @@ public: dwarf::Attribute Attr; dwarf::Form Form; + /// The following field is used for ByteSize for non-implicit_const /// attributes and as value for implicit_const ones, indicated by /// Form == DW_FORM_implicit_const. @@ -58,7 +59,7 @@ public: /// the ByteSize member. Optional getByteSize(const DWARFUnit &U) const; }; - typedef SmallVector AttributeSpecVector; + using AttributeSpecVector = SmallVector; DWARFAbbreviationDeclaration(); @@ -67,8 +68,8 @@ public: dwarf::Tag getTag() const { return Tag; } bool hasChildren() const { return HasChildren; } - typedef iterator_range - attr_iterator_range; + using attr_iterator_range = + iterator_range; attr_iterator_range attributes() const { return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end()); diff --git a/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h index 3012b39dcc5..8bde63efe18 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ b/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -32,8 +32,9 @@ class DWARFAcceleratorTable { }; struct HeaderData { - typedef uint16_t AtomType; - typedef dwarf::Form Form; + using AtomType = uint16_t; + using Form = dwarf::Form; + uint32_t DIEOffsetBase; SmallVector, 3> Atoms; }; diff --git a/include/llvm/DebugInfo/DWARF/DWARFContext.h b/include/llvm/DebugInfo/DWARF/DWARFContext.h index c72604a12bf..4bf34d52bcb 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ b/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -10,7 +10,6 @@ #ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H #define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H -#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" @@ -25,21 +24,24 @@ #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" +#include "llvm/DebugInfo/DWARF/DWARFDie.h" #include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h" #include "llvm/DebugInfo/DWARF/DWARFSection.h" #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" #include "llvm/DebugInfo/DWARF/DWARFUnit.h" #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" +#include "llvm/Object/Binary.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Support/Error.h" #include "llvm/Support/Host.h" #include #include #include #include -#include namespace llvm { +class DataExtractor; class MemoryBuffer; class raw_ostream; @@ -73,7 +75,7 @@ class DWARFContext : public DIContext { std::unique_ptr LocDWO; /// The maximum DWARF version of all units. - unsigned MaxVersion; + unsigned MaxVersion = 0; struct DWOFile { object::OwningBinary File; @@ -100,7 +102,7 @@ class DWARFContext : public DIContext { void parseDWOTypeUnits(); public: - DWARFContext() : DIContext(CK_DWARF), MaxVersion(0) {} + DWARFContext() : DIContext(CK_DWARF) {} DWARFContext(DWARFContext &) = delete; DWARFContext &operator=(DWARFContext &) = delete; @@ -112,9 +114,9 @@ public: bool verify(raw_ostream &OS, DIDumpType DumpType = DIDT_All) override; - typedef DWARFUnitSection::iterator_range cu_iterator_range; - typedef DWARFUnitSection::iterator_range tu_iterator_range; - typedef iterator_range tu_section_iterator_range; + using cu_iterator_range = DWARFUnitSection::iterator_range; + using tu_iterator_range = DWARFUnitSection::iterator_range; + using tu_section_iterator_range = iterator_range; /// Get compile units in this context. cu_iterator_range compile_units() { @@ -230,8 +232,10 @@ public: virtual bool isLittleEndian() const = 0; virtual uint8_t getAddressSize() const = 0; virtual const DWARFSection &getInfoSection() = 0; - typedef MapVector> TypeSectionMap; + + using TypeSectionMap = MapVector>; + virtual const TypeSectionMap &getTypesSections() = 0; virtual StringRef getAbbrevSection() = 0; virtual const DWARFSection &getLocSection() = 0; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h index 9f86fe50838..65571598d74 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h @@ -18,6 +18,8 @@ namespace llvm { +class raw_ostream; + class DWARFAbbreviationDeclarationSet { uint32_t Offset; /// Code of the first abbreviation, if all abbreviations in the set have @@ -25,8 +27,8 @@ class DWARFAbbreviationDeclarationSet { uint32_t FirstAbbrCode; std::vector Decls; - typedef std::vector::const_iterator - const_iterator; + using const_iterator = + std::vector::const_iterator; public: DWARFAbbreviationDeclarationSet(); @@ -51,8 +53,8 @@ private: }; class DWARFDebugAbbrev { - typedef std::map - DWARFAbbreviationDeclarationSetMap; + using DWARFAbbreviationDeclarationSetMap = + std::map; DWARFAbbreviationDeclarationSetMap AbbrDeclSets; mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h b/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h index 2d82104ea09..dfbbb95076e 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h @@ -46,8 +46,8 @@ public: }; private: - typedef std::vector DescriptorColl; - typedef iterator_range desc_iterator_range; + using DescriptorColl = std::vector; + using desc_iterator_range = iterator_range; uint32_t Offset; Header HeaderData; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h b/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h index 2237aa361d1..ea71a50f327 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h @@ -76,8 +76,8 @@ private: } }; - typedef std::vector RangeColl; - typedef RangeColl::const_iterator RangeCollIterator; + using RangeColl = std::vector; + using RangeCollIterator = RangeColl::const_iterator; std::vector Endpoints; RangeColl Aranges; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h index 39a7ef71de9..e6a589c2b92 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -10,6 +10,7 @@ #ifndef LLVM_DEBUGINFO_DWARFDEBUGLINE_H #define LLVM_DEBUGINFO_DWARFDEBUGLINE_H +#include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" #include "llvm/Support/DataExtractor.h" @@ -104,7 +105,9 @@ public: void postAppend(); void reset(bool DefaultIsStmt); void dump(raw_ostream &OS) const; + static void dumpTableHeader(raw_ostream &OS); + static bool orderByAddress(const Row &LHS, const Row &RHS) { return LHS.Address < RHS.Address; } @@ -216,11 +219,12 @@ public: bool parse(DataExtractor DebugLineData, const RelocAddrMap *RMap, uint32_t *OffsetPtr); + using RowVector = std::vector; + using RowIter = RowVector::const_iterator; + using SequenceVector = std::vector; + using SequenceIter = SequenceVector::const_iterator; + struct Prologue Prologue; - typedef std::vector RowVector; - typedef RowVector::const_iterator RowIter; - typedef std::vector SequenceVector; - typedef SequenceVector::const_iterator SequenceIter; RowVector Rows; SequenceVector Sequences; @@ -244,14 +248,14 @@ private: struct LineTable *LineTable; /// The row number that starts at zero for the prologue, and increases for /// each row added to the matrix. - unsigned RowNumber; + unsigned RowNumber = 0; struct Row Row; struct Sequence Sequence; }; - typedef std::map LineTableMapTy; - typedef LineTableMapTy::iterator LineTableIter; - typedef LineTableMapTy::const_iterator LineTableConstIter; + using LineTableMapTy = std::map; + using LineTableIter = LineTableMapTy::iterator; + using LineTableConstIter = LineTableMapTy::const_iterator; const RelocAddrMap *RelocMap; LineTableMapTy LineTableMap; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h b/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h index 6d4cd8d1b5a..821da8f9b53 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h @@ -39,7 +39,7 @@ class DWARFDebugLoc { SmallVector Entries; }; - typedef SmallVector LocationLists; + using LocationLists = SmallVector; /// A list of all the variables in the debug_loc section, each one describing /// the locations in which the variable is stored. @@ -71,7 +71,7 @@ class DWARFDebugLocDWO { SmallVector Entries; }; - typedef SmallVector LocationLists; + using LocationLists = SmallVector; LocationLists Locations; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h b/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h index 85d98b45afc..135c50761e3 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h @@ -40,7 +40,7 @@ class DWARFDebugMacro { }; }; - typedef SmallVector MacroList; + using MacroList = SmallVector; /// A list of all the macro entries in the debug_macinfo section. MacroList Macros; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h b/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h index 437060bc8fe..49beec92ecc 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h @@ -12,10 +12,8 @@ #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" #include "llvm/Support/DataExtractor.h" - #include #include -#include #include namespace llvm { @@ -29,7 +27,7 @@ struct DWARFAddressRange { }; /// DWARFAddressRangesVector - represents a set of absolute address ranges. -typedef std::vector DWARFAddressRangesVector; +using DWARFAddressRangesVector = std::vector; class DWARFDebugRangeList { public: diff --git a/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h b/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h index f143de33473..f5183842461 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h +++ b/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h @@ -12,7 +12,6 @@ #include "llvm/ADT/DenseMap.h" #include -#include namespace llvm { @@ -28,7 +27,7 @@ struct RelocAddrEntry { /// dwarf where we expect relocated values. This adds a bit of complexity to the /// dwarf parsing/extraction at the benefit of not allocating memory for the /// entire size of the debug info sections. -typedef DenseMap RelocAddrMap; +using RelocAddrMap = DenseMap; } // end namespace llvm diff --git a/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/include/llvm/DebugInfo/DWARF/DWARFUnit.h index 945b8999ff2..fd276062ba4 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ b/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -22,8 +22,6 @@ #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" #include "llvm/DebugInfo/DWARF/DWARFSection.h" #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" -#include "llvm/Object/Binary.h" -#include "llvm/Object/ObjectFile.h" #include "llvm/Support/DataExtractor.h" #include #include @@ -31,6 +29,7 @@ #include #include #include +#include #include namespace llvm { @@ -72,9 +71,9 @@ class DWARFUnitSection final : public SmallVector, 1>, bool Parsed = false; public: - typedef SmallVectorImpl> UnitVector; - typedef typename UnitVector::iterator iterator; - typedef llvm::iterator_range iterator_range; + using UnitVector = SmallVectorImpl>; + using iterator = typename UnitVector::iterator; + using iterator_range = llvm::iterator_range; UnitType *getUnitForOffset(uint32_t Offset) const override { auto *CU = std::upper_bound( @@ -142,8 +141,9 @@ class DWARFUnit { /// IntervalMap does not support range removal, as a result, we use the /// std::map::upper_bound for address range lookup. std::map> AddrDieMap; - typedef iterator_range::iterator> - die_iterator_range; + + using die_iterator_range = + iterator_range::iterator>; std::shared_ptr DWO; diff --git a/include/llvm/DebugInfo/MSF/MSFBuilder.h b/include/llvm/DebugInfo/MSF/MSFBuilder.h index 6d067cc1c23..b2c8f2d1c20 100644 --- a/include/llvm/DebugInfo/MSF/MSFBuilder.h +++ b/include/llvm/DebugInfo/MSF/MSFBuilder.h @@ -12,18 +12,16 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitVector.h" - #include "llvm/DebugInfo/MSF/MSFCommon.h" - #include "llvm/Support/Allocator.h" -#include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" - +#include #include #include namespace llvm { namespace msf { + class MSFBuilder { public: /// \brief Create a new `MSFBuilder`. @@ -122,7 +120,7 @@ private: Error allocateBlocks(uint32_t NumBlocks, MutableArrayRef Blocks); uint32_t computeDirectoryByteSize() const; - typedef std::vector BlockList; + using BlockList = std::vector; BumpPtrAllocator &Allocator; @@ -136,7 +134,8 @@ private: std::vector DirectoryBlocks; std::vector> StreamData; }; -} // namespace msf -} // namespace llvm + +} // end namespace msf +} // end namespace llvm #endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H diff --git a/include/llvm/DebugInfo/MSF/MSFCommon.h b/include/llvm/DebugInfo/MSF/MSFCommon.h index 93a9c808b73..eca1b8b89eb 100644 --- a/include/llvm/DebugInfo/MSF/MSFCommon.h +++ b/include/llvm/DebugInfo/MSF/MSFCommon.h @@ -12,15 +12,15 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitVector.h" - #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include "llvm/Support/MathExtras.h" - +#include #include namespace llvm { namespace msf { + static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', ' ', 'C', '/', 'C', '+', '+', ' ', 'M', 'S', 'F', ' ', '7', '.', '0', '0', @@ -50,8 +50,9 @@ struct SuperBlock { }; struct MSFLayout { - MSFLayout() : SB(nullptr) {} - const SuperBlock *SB; + MSFLayout() = default; + + const SuperBlock *SB = nullptr; BitVector FreePageMap; ArrayRef DirectoryBlocks; ArrayRef StreamSizes; @@ -90,15 +91,16 @@ inline uint32_t getFpmIntervalLength(const MSFLayout &L) { inline uint32_t getNumFpmIntervals(const MSFLayout &L) { uint32_t Length = getFpmIntervalLength(L); - return llvm::alignTo(L.SB->NumBlocks, Length) / Length; + return alignTo(L.SB->NumBlocks, Length) / Length; } inline uint32_t getFullFpmByteSize(const MSFLayout &L) { - return llvm::alignTo(L.SB->NumBlocks, 8) / 8; + return alignTo(L.SB->NumBlocks, 8) / 8; } Error validateSuperBlock(const SuperBlock &SB); -} // namespace msf -} // namespace llvm + +} // end namespace msf +} // end namespace llvm #endif // LLVM_DEBUGINFO_MSF_MSFCOMMON_H diff --git a/include/llvm/DebugInfo/MSF/MappedBlockStream.h b/include/llvm/DebugInfo/MSF/MappedBlockStream.h index 02f3cb09b00..6d88d2be85c 100644 --- a/include/llvm/DebugInfo/MSF/MappedBlockStream.h +++ b/include/llvm/DebugInfo/MSF/MappedBlockStream.h @@ -1,5 +1,4 @@ -//===- MappedBlockStream.h - Discontiguous stream data in an MSF -*- C++ -//-*-===// +//==- MappedBlockStream.h - Discontiguous stream data in an MSF --*- C++ -*-==// // // The LLVM Compiler Infrastructure // @@ -13,7 +12,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/DebugInfo/MSF/MSFStreamLayout.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryStream.h" @@ -21,6 +19,7 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include +#include #include namespace llvm { @@ -40,6 +39,7 @@ struct MSFLayout; /// of bytes. class MappedBlockStream : public BinaryStream { friend class WritableMappedBlockStream; + public: static std::unique_ptr createStream(uint32_t BlockSize, const MSFStreamLayout &Layout, @@ -57,8 +57,8 @@ public: createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData, BumpPtrAllocator &Allocator); - llvm::support::endianness getEndian() const override { - return llvm::support::little; + support::endianness getEndian() const override { + return support::little; } Error readBytes(uint32_t Offset, uint32_t Size, @@ -68,7 +68,7 @@ public: uint32_t getLength() override; - llvm::BumpPtrAllocator &getAllocator() { return Allocator; } + BumpPtrAllocator &getAllocator() { return Allocator; } void invalidateCache(); @@ -92,7 +92,7 @@ private: const MSFStreamLayout StreamLayout; BinaryStreamRef MsfData; - typedef MutableArrayRef CacheEntry; + using CacheEntry = MutableArrayRef; // We just store the allocator by reference. We use this to allocate // contiguous memory for things like arrays or strings that cross a block @@ -124,8 +124,8 @@ public: createFpmStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, BumpPtrAllocator &Allocator); - llvm::support::endianness getEndian() const override { - return llvm::support::little; + support::endianness getEndian() const override { + return support::little; } Error readBytes(uint32_t Offset, uint32_t Size, @@ -141,6 +141,7 @@ public: const MSFStreamLayout &getStreamLayout() const { return ReadInterface.getStreamLayout(); } + uint32_t getBlockSize() const { return ReadInterface.getBlockSize(); } uint32_t getNumBlocks() const { return ReadInterface.getNumBlocks(); } uint32_t getStreamLength() const { return ReadInterface.getStreamLength(); } @@ -153,7 +154,6 @@ protected: private: MappedBlockStream ReadInterface; - WritableBinaryStreamRef WriteInterface; }; diff --git a/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h b/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h index e0bec6f6cf8..e576a91e887 100644 --- a/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h +++ b/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h @@ -1,4 +1,4 @@ -//===-- SymbolizableModule.h ------------------------------------ C++ -----===// +//===- SymbolizableModule.h -------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,12 +14,7 @@ #define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H #include "llvm/DebugInfo/DIContext.h" - -namespace llvm { -namespace object { -class ObjectFile; -} -} +#include namespace llvm { namespace symbolize { @@ -28,7 +23,8 @@ using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; class SymbolizableModule { public: - virtual ~SymbolizableModule() {} + virtual ~SymbolizableModule() = default; + virtual DILineInfo symbolizeCode(uint64_t ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const = 0; @@ -45,7 +41,7 @@ public: virtual uint64_t getModulePreferredBase() const = 0; }; -} // namespace symbolize -} // namespace llvm +} // end namespace symbolize +} // end namespace llvm #endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H diff --git a/include/llvm/DebugInfo/Symbolize/Symbolize.h b/include/llvm/DebugInfo/Symbolize/Symbolize.h index 5103cc03a6b..d98d49b24bc 100644 --- a/include/llvm/DebugInfo/Symbolize/Symbolize.h +++ b/include/llvm/DebugInfo/Symbolize/Symbolize.h @@ -1,4 +1,4 @@ -//===-- Symbolize.h --------------------------------------------- C++ -----===// +//===- Symbolize.h ----------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -10,21 +10,27 @@ // Header for LLVM symbolization library. // //===----------------------------------------------------------------------===// + #ifndef LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H #define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H #include "llvm/DebugInfo/Symbolize/SymbolizableModule.h" +#include "llvm/Object/Binary.h" #include "llvm/Object/ObjectFile.h" -#include "llvm/Support/ErrorOr.h" +#include "llvm/Support/Error.h" +#include +#include #include #include #include #include +#include namespace llvm { namespace symbolize { using namespace object; + using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; class LLVMSymbolizer { @@ -36,6 +42,7 @@ public: bool RelativeAddresses : 1; std::string DefaultArch; std::vector DsymHints; + Options(FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName, bool UseSymbolTable = true, bool Demangle = true, bool RelativeAddresses = false, std::string DefaultArch = "") @@ -45,6 +52,7 @@ public: }; LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {} + ~LLVMSymbolizer() { flush(); } @@ -56,6 +64,7 @@ public: Expected symbolizeData(const std::string &ModuleName, uint64_t ModuleOffset); void flush(); + static std::string DemangleName(const std::string &Name, const SymbolizableModule *DbiModuleDescriptor); @@ -63,7 +72,7 @@ public: private: // Bundles together object file with code/data and object file with // corresponding debug info. These objects can be the same. - typedef std::pair ObjectPair; + using ObjectPair = std::pair; /// Returns a SymbolizableModule or an error if loading debug info failed. /// Only one attempt is made to load a module, and errors during loading are @@ -106,7 +115,7 @@ private: Options Opts; }; -} // namespace symbolize -} // namespace llvm +} // end namespace symbolize +} // end namespace llvm -#endif +#endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H diff --git a/lib/DebugInfo/DWARF/DWARFContext.cpp b/lib/DebugInfo/DWARF/DWARFContext.cpp index 9bafcde57f0..38147946175 100644 --- a/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -13,6 +13,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" @@ -36,7 +37,6 @@ #include "llvm/Object/RelocVisitor.h" #include "llvm/Support/Casting.h" #include "llvm/Support/DataExtractor.h" -#include "llvm/Support/Debug.h" #include "llvm/Support/Error.h" #include "llvm/Support/Format.h" #include "llvm/Support/MemoryBuffer.h" @@ -44,8 +44,8 @@ #include #include #include -#include #include +#include #include #include @@ -55,9 +55,9 @@ using namespace object; #define DEBUG_TYPE "dwarf" -typedef DWARFDebugLine::LineTable DWARFLineTable; -typedef DILineInfoSpecifier::FileLineInfoKind FileLineInfoKind; -typedef DILineInfoSpecifier::FunctionNameKind FunctionNameKind; +using DWARFLineTable = DWARFDebugLine::LineTable; +using FileLineInfoKind = DILineInfoSpecifier::FileLineInfoKind; +using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; uint64_t llvm::getRelocatedValue(const DataExtractor &Data, uint32_t Size, uint32_t *Off, const RelocAddrMap *Relocs, @@ -201,8 +201,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName, } } -void DWARFContext::dump(raw_ostream &OS, DIDumpOptions DumpOpts){ - +void DWARFContext::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { DIDumpType DumpType = DumpOpts.DumpType; bool DumpEH = DumpOpts.DumpEH; bool SummarizeTypes = DumpOpts.SummarizeTypes; @@ -1068,7 +1067,7 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj, errs() << "error: failed to compute relocation: " << Name << "\n"; continue; } - llvm::RelocAddrEntry Rel = {SymInfoOrErr->SectionIndex, Val}; + RelocAddrEntry Rel = {SymInfoOrErr->SectionIndex, Val}; Map->insert({Reloc.getOffset(), Rel}); } } diff --git a/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp index f0caf2e5c6b..475cf25b781 100644 --- a/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ b/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h" - #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" @@ -71,7 +70,7 @@ protected: /// An entry may contain CFI instructions. An instruction consists of an /// opcode and an optional sequence of operands. - typedef std::vector Operands; + using Operands = std::vector; struct Instruction { Instruction(uint8_t Opcode) : Opcode(Opcode) diff --git a/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index cda3e75fbc3..72d8760751d 100644 --- a/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -9,6 +9,8 @@ #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" @@ -26,13 +28,17 @@ using namespace llvm; using namespace dwarf; -typedef DILineInfoSpecifier::FileLineInfoKind FileLineInfoKind; +using FileLineInfoKind = DILineInfoSpecifier::FileLineInfoKind; + namespace { + struct ContentDescriptor { dwarf::LineNumberEntryFormat Type; dwarf::Form Form; }; -typedef SmallVector ContentDescriptors; + +using ContentDescriptors = SmallVector; + } // end anonmyous namespace DWARFDebugLine::Prologue::Prologue() { clear(); } @@ -333,7 +339,7 @@ void DWARFDebugLine::LineTable::clear() { } DWARFDebugLine::ParsingState::ParsingState(struct LineTable *LT) - : LineTable(LT), RowNumber(0) { + : LineTable(LT) { resetRowAndSequence(); } diff --git a/lib/DebugInfo/DWARF/DWARFUnit.cpp b/lib/DebugInfo/DWARF/DWARFUnit.cpp index 09e6a292e5f..ded9b2abf64 100644 --- a/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -1,4 +1,4 @@ -//===-- DWARFUnit.cpp -----------------------------------------------------===// +//===- DWARFUnit.cpp ------------------------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/DWARF/DWARFUnit.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" @@ -17,8 +16,6 @@ #include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h" #include "llvm/DebugInfo/DWARF/DWARFDie.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" -#include "llvm/Object/ObjectFile.h" -#include "llvm/Support/Casting.h" #include "llvm/Support/DataExtractor.h" #include "llvm/Support/Path.h" #include @@ -26,6 +23,7 @@ #include #include #include +#include #include using namespace llvm; @@ -55,8 +53,8 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section, const DWARFUnitIndex::Entry *IndexEntry) : Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS), LineSection(LS), StringSection(SS), StringOffsetSection(SOS), - StringOffsetSectionBase(0), AddrOffsetSection(AOS), isLittleEndian(LE), - isDWO(IsDWO), UnitSection(UnitSection), IndexEntry(IndexEntry) { + AddrOffsetSection(AOS), isLittleEndian(LE), isDWO(IsDWO), + UnitSection(UnitSection), IndexEntry(IndexEntry) { clear(); } diff --git a/lib/DebugInfo/MSF/MSFBuilder.cpp b/lib/DebugInfo/MSF/MSFBuilder.cpp index 5b1b5d8dc4d..0f4f785abf5 100644 --- a/lib/DebugInfo/MSF/MSFBuilder.cpp +++ b/lib/DebugInfo/MSF/MSFBuilder.cpp @@ -1,3 +1,4 @@ +//===- MSFBuilder.cpp -----------------------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -6,22 +7,30 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/ArrayRef.h" #include "llvm/DebugInfo/MSF/MSFBuilder.h" #include "llvm/DebugInfo/MSF/MSFError.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include +#include +#include +#include +#include +#include +#include using namespace llvm; using namespace llvm::msf; using namespace llvm::support; -namespace { -const uint32_t kSuperBlockBlock = 0; -const uint32_t kFreePageMap0Block = 1; -const uint32_t kFreePageMap1Block = 2; -const uint32_t kNumReservedPages = 3; +static const uint32_t kSuperBlockBlock = 0; +static const uint32_t kFreePageMap0Block = 1; +static const uint32_t kFreePageMap1Block = 2; +static const uint32_t kNumReservedPages = 3; -const uint32_t kDefaultFreePageMap = kFreePageMap0Block; -const uint32_t kDefaultBlockMapAddr = kNumReservedPages; -} +static const uint32_t kDefaultFreePageMap = kFreePageMap0Block; +static const uint32_t kDefaultBlockMapAddr = kNumReservedPages; MSFBuilder::MSFBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow, BumpPtrAllocator &Allocator) @@ -263,7 +272,7 @@ Expected MSFBuilder::build() { // The stream sizes should be re-allocated as a stable pointer and the stream // map should have each of its entries allocated as a separate stable pointer. - if (StreamData.size() > 0) { + if (!StreamData.empty()) { ulittle32_t *Sizes = Allocator.Allocate(StreamData.size()); L.StreamSizes = ArrayRef(Sizes, StreamData.size()); L.StreamMap.resize(StreamData.size()); diff --git a/lib/DebugInfo/MSF/MSFCommon.cpp b/lib/DebugInfo/MSF/MSFCommon.cpp index fdab7884646..1facf5efb4b 100644 --- a/lib/DebugInfo/MSF/MSFCommon.cpp +++ b/lib/DebugInfo/MSF/MSFCommon.cpp @@ -1,4 +1,4 @@ -//===- MSFCommon.cpp - Common types and functions for MSF files -*- C++ -*-===// +//===- MSFCommon.cpp - Common types and functions for MSF files -----------===// // // The LLVM Compiler Infrastructure // @@ -9,6 +9,10 @@ #include "llvm/DebugInfo/MSF/MSFCommon.h" #include "llvm/DebugInfo/MSF/MSFError.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include +#include using namespace llvm; using namespace llvm::msf; diff --git a/lib/DebugInfo/MSF/MappedBlockStream.cpp b/lib/DebugInfo/MSF/MappedBlockStream.cpp index faf2442bc94..e45f4ae0ed9 100644 --- a/lib/DebugInfo/MSF/MappedBlockStream.cpp +++ b/lib/DebugInfo/MSF/MappedBlockStream.cpp @@ -8,23 +8,33 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/MSF/MappedBlockStream.h" - -#include "llvm/DebugInfo/MSF/IMSFFile.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/DebugInfo/MSF/MSFCommon.h" #include "llvm/DebugInfo/MSF/MSFStreamLayout.h" -#include "llvm/Support/BinaryStreamError.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/MathExtras.h" +#include +#include +#include +#include +#include +#include using namespace llvm; using namespace llvm::msf; namespace { + template class MappedBlockStreamImpl : public Base { public: template MappedBlockStreamImpl(Args &&... Params) : Base(std::forward(Params)...) {} }; -} + +} // end anonymous namespace static void initializeFpmStreamLayout(const MSFLayout &Layout, MSFStreamLayout &FpmLayout) { @@ -39,7 +49,8 @@ static void initializeFpmStreamLayout(const MSFLayout &Layout, FpmLayout.Length = msf::getFullFpmByteSize(Layout); } -typedef std::pair Interval; +using Interval = std::pair; + static Interval intersect(const Interval &I1, const Interval &I2) { return std::make_pair(std::max(I1.first, I2.first), std::min(I1.second, I2.second)); @@ -214,7 +225,7 @@ bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size, uint32_t OffsetInBlock = Offset % BlockSize; uint32_t BytesFromFirstBlock = std::min(Size, BlockSize - OffsetInBlock); uint32_t NumAdditionalBlocks = - llvm::alignTo(Size - BytesFromFirstBlock, BlockSize) / BlockSize; + alignTo(Size - BytesFromFirstBlock, BlockSize) / BlockSize; uint32_t RequiredContiguousBlocks = NumAdditionalBlocks + 1; uint32_t E = StreamLayout.Blocks[BlockNum];