From 570e39a25ca345e3facaea16b2facefddfb3aa92 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Wed, 23 Nov 2016 23:16:32 +0000 Subject: [PATCH] [DebugInfo] Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes (NFC). Per Zachary Turner and Mehdi Amini suggestion to make only post-commit reviews. llvm-svn: 287838 --- llvm/include/llvm/DebugInfo/PDB/Raw/ModInfo.h | 2 +- llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp | 5 ++-- llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp | 25 ++++++++++---------- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 31 +++++++++++++++++-------- llvm/lib/DebugInfo/PDB/IPDBSourceFile.cpp | 8 ++++--- llvm/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp | 9 ++++--- llvm/lib/DebugInfo/PDB/PDBSymDumper.cpp | 2 +- llvm/lib/DebugInfo/PDB/PDBSymbol.cpp | 11 ++++----- llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp | 15 ++++++++---- llvm/lib/DebugInfo/PDB/Raw/GlobalsStream.cpp | 12 ++++------ llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp | 19 +++++++-------- llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp | 26 ++++++++++++--------- llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp | 16 ++++++++----- llvm/lib/DebugInfo/PDB/Raw/NameMapBuilder.cpp | 9 ++++--- llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp | 19 ++++++++------- llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp | 20 +++++++--------- llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp | 25 ++++++++++---------- llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp | 15 ++++++------ llvm/lib/DebugInfo/PDB/Raw/TpiStreamBuilder.cpp | 24 ++++++++++++++++--- 19 files changed, 167 insertions(+), 126 deletions(-) diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/ModInfo.h b/llvm/include/llvm/DebugInfo/PDB/Raw/ModInfo.h index 034da4b..bf5cf53 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/ModInfo.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/ModInfo.h @@ -50,7 +50,7 @@ public: private: StringRef ModuleName; StringRef ObjFileName; - const ModuleInfoHeader *Layout; + const ModuleInfoHeader *Layout = nullptr; }; struct ModuleInfoEx { diff --git a/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp index 39a7c77..faa51e0 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" @@ -29,5 +31,4 @@ void DWARFCompileUnit::dump(raw_ostream &OS) { } // VTable anchor. -DWARFCompileUnit::~DWARFCompileUnit() { -} +DWARFCompileUnit::~DWARFCompileUnit() = default; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp index 046559e..32b8320 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -37,11 +37,11 @@ using namespace dwarf; class llvm::FrameEntry { public: enum FrameKind {FK_CIE, FK_FDE}; + FrameEntry(FrameKind K, uint64_t Offset, uint64_t Length) : Kind(K), Offset(Offset), Length(Length) {} - virtual ~FrameEntry() { - } + virtual ~FrameEntry() = default; FrameKind getKind() const { return Kind; } virtual uint64_t getOffset() const { return Offset; } @@ -220,7 +220,7 @@ public: FDEPointerEncoding(FDEPointerEncoding), LSDAPointerEncoding(LSDAPointerEncoding) {} - ~CIE() override {} + ~CIE() override = default; StringRef getAugmentationString() const { return Augmentation; } uint64_t getCodeAlignmentFactor() const { return CodeAlignmentFactor; } @@ -294,7 +294,7 @@ public: InitialLocation(InitialLocation), AddressRange(AddressRange), LinkedCIE(Cie) {} - ~FDE() override {} + ~FDE() override = default; CIE *getLinkedCIE() const { return LinkedCIE; } @@ -468,8 +468,7 @@ void FrameEntry::dumpInstructions(raw_ostream &OS) const { DWARFDebugFrame::DWARFDebugFrame(bool IsEH) : IsEH(IsEH) { } -DWARFDebugFrame::~DWARFDebugFrame() { -} +DWARFDebugFrame::~DWARFDebugFrame() = default; static void LLVM_ATTRIBUTE_UNUSED dumpDataAux(DataExtractor Data, uint32_t Offset, int Length) { @@ -620,12 +619,14 @@ void DWARFDebugFrame::parse(DataExtractor Data) { } } - auto Cie = make_unique(StartOffset, Length, Version, - AugmentationString, AddressSize, - SegmentDescriptorSize, CodeAlignmentFactor, - DataAlignmentFactor, ReturnAddressRegister, - AugmentationData, FDEPointerEncoding, - LSDAPointerEncoding); + auto Cie = llvm::make_unique(StartOffset, Length, Version, + AugmentationString, AddressSize, + SegmentDescriptorSize, + CodeAlignmentFactor, + DataAlignmentFactor, + ReturnAddressRegister, + AugmentationData, FDEPointerEncoding, + LSDAPointerEncoding); CIEs[StartOffset] = Cie.get(); Entries.emplace_back(std::move(Cie)); } else { diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 85ef3e4..caa3694 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -7,14 +7,25 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/DWARF/DWARFUnit.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" -#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" -#include "llvm/Support/Dwarf.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" +#include "llvm/DebugInfo/DWARF/DWARFUnit.h" +#include "llvm/Object/ObjectFile.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/DataExtractor.h" #include "llvm/Support/Path.h" +#include +#include +#include #include +#include namespace llvm { + using namespace dwarf; void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) { @@ -49,8 +60,7 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section, clear(); } -DWARFUnit::~DWARFUnit() { -} +DWARFUnit::~DWARFUnit() = default; bool DWARFUnit::getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const { @@ -121,7 +131,7 @@ bool DWARFUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) { bool DWARFUnit::extractRangeList(uint32_t RangeListOffset, DWARFDebugRangeList &RangeList) const { // Require that compile unit is extracted. - assert(DieArray.size() > 0); + assert(!DieArray.empty()); DataExtractor RangesData(RangeSection, isLittleEndian, AddrSize); uint32_t ActualRangeListOffset = RangeSectionBase + RangeListOffset; return RangeList.extract(RangesData, &ActualRangeListOffset); @@ -238,11 +248,11 @@ void DWARFUnit::extractDIEsToVector( } size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) { - if ((CUDieOnly && DieArray.size() > 0) || + if ((CUDieOnly && !DieArray.empty()) || DieArray.size() > 1) return 0; // Already parsed. - bool HasCUDie = DieArray.size() > 0; + bool HasCUDie = !DieArray.empty(); extractDIEsToVector(!HasCUDie, !CUDieOnly, DieArray); if (DieArray.empty()) @@ -268,7 +278,7 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) { } DWARFUnit::DWOHolder::DWOHolder(StringRef DWOPath) - : DWOFile(), DWOContext(), DWOU(nullptr) { + : DWOU(nullptr) { auto Obj = object::ObjectFile::createObjectFile(DWOPath); if (!Obj) { // TODO: Actually report errors helpfully. @@ -404,4 +414,5 @@ const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context, assert(Kind == DW_SECT_TYPES); return Context.getTUIndex(); } -} + +} // end namespace llvm diff --git a/llvm/lib/DebugInfo/PDB/IPDBSourceFile.cpp b/llvm/lib/DebugInfo/PDB/IPDBSourceFile.cpp index 46b422f5..8cb1fbe 100644 --- a/llvm/lib/DebugInfo/PDB/IPDBSourceFile.cpp +++ b/llvm/lib/DebugInfo/PDB/IPDBSourceFile.cpp @@ -1,4 +1,4 @@ -//===- IPDBSourceFile.cpp - base interface for a PDB source file *- C++ -*-===// +//===- IPDBSourceFile.cpp - base interface for a PDB source file ----------===// // // The LLVM Compiler Infrastructure // @@ -8,15 +8,17 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/PDB/IPDBSourceFile.h" - #include "llvm/DebugInfo/PDB/PDBExtras.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" +#include +#include using namespace llvm; using namespace llvm::pdb; -IPDBSourceFile::~IPDBSourceFile() {} +IPDBSourceFile::~IPDBSourceFile() = default; void IPDBSourceFile::dump(raw_ostream &OS, int Indent) const { OS.indent(Indent); diff --git a/llvm/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp b/llvm/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp index a347c67..541fcda 100644 --- a/llvm/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp @@ -15,15 +15,14 @@ #include "llvm/DebugInfo/PDB/IPDBLineNumber.h" #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" #include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" using namespace llvm; using namespace llvm::pdb; -IPDBSession::~IPDBSession() {} +IPDBSession::~IPDBSession() = default; -IPDBDataStream::~IPDBDataStream() {} +IPDBDataStream::~IPDBDataStream() = default; -IPDBRawSymbol::~IPDBRawSymbol() {} +IPDBRawSymbol::~IPDBRawSymbol() = default; -IPDBLineNumber::~IPDBLineNumber() {} +IPDBLineNumber::~IPDBLineNumber() = default; diff --git a/llvm/lib/DebugInfo/PDB/PDBSymDumper.cpp b/llvm/lib/DebugInfo/PDB/PDBSymDumper.cpp index 9450a98..2f81931 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymDumper.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymDumper.cpp @@ -20,7 +20,7 @@ using namespace llvm::pdb; PDBSymDumper::PDBSymDumper(bool ShouldRequireImpl) : RequireImpl(ShouldRequireImpl) {} -PDBSymDumper::~PDBSymDumper() {} +PDBSymDumper::~PDBSymDumper() = default; void PDBSymDumper::dump(const PDBSymbolAnnotation &Symbol) { PDB_SYMDUMP_UNREACHABLE(PDBSymbolAnnotation) diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp index 78b3afc..633e11a 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/PDB/PDBSymbol.h" - #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include "llvm/DebugInfo/PDB/PDBExtras.h" #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h" #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h" #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" @@ -42,12 +42,9 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h" #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h" #include "llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h" -#include "llvm/DebugInfo/PDB/PDBSymDumper.h" -#include -#include - +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include #include -#include using namespace llvm; using namespace llvm::pdb; @@ -56,7 +53,7 @@ PDBSymbol::PDBSymbol(const IPDBSession &PDBSession, std::unique_ptr Symbol) : Session(PDBSession), RawSymbol(std::move(Symbol)) {} -PDBSymbol::~PDBSymbol() {} +PDBSymbol::~PDBSymbol() = default; #define FACTORY_SYMTAG_CASE(Tag, Type) \ case PDB_SymType::Tag: \ diff --git a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp index 9ed3470..4f4a0cf 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp @@ -7,11 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/DbiStream.h" - +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/MSF/StreamArray.h" #include "llvm/DebugInfo/MSF/StreamReader.h" -#include "llvm/DebugInfo/MSF/StreamWriter.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/DebugInfo/PDB/Raw/DbiStream.h" #include "llvm/DebugInfo/PDB/Raw/ISectionContribVisitor.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" #include "llvm/DebugInfo/PDB/Raw/ModInfo.h" @@ -21,6 +22,10 @@ #include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h" #include "llvm/Object/COFF.h" +#include "llvm/Support/Error.h" +#include +#include +#include using namespace llvm; using namespace llvm::codeview; @@ -46,7 +51,7 @@ DbiStream::DbiStream(PDBFile &File, std::unique_ptr Stream) : Pdb(File), Stream(std::move(Stream)), Header(nullptr) { } -DbiStream::~DbiStream() {} +DbiStream::~DbiStream() = default; Error DbiStream::reload() { StreamReader Reader(*Stream); @@ -217,7 +222,7 @@ msf::FixedStreamArray DbiStream::getSectionMap() const { return SectionMap; } -void llvm::pdb::DbiStream::visitSectionContributions( +void DbiStream::visitSectionContributions( ISectionContribVisitor &Visitor) const { if (SectionContribVersion == DbiSecContribVer60) { for (auto &SC : SectionContribs) diff --git a/llvm/lib/DebugInfo/PDB/Raw/GlobalsStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/GlobalsStream.cpp index c518452..31afc92 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/GlobalsStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/GlobalsStream.cpp @@ -7,15 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/GlobalsStream.h" - #include "GSI.h" -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" -#include "llvm/DebugInfo/PDB/Raw/RawError.h" -#include "llvm/DebugInfo/PDB/Raw/RawTypes.h" - -#include "llvm/Support/Endian.h" +#include "llvm/DebugInfo/MSF/StreamReader.h" +#include "llvm/DebugInfo/PDB/Raw/GlobalsStream.h" #include "llvm/Support/Error.h" +#include using namespace llvm; using namespace llvm::msf; @@ -24,7 +20,7 @@ using namespace llvm::pdb; GlobalsStream::GlobalsStream(std::unique_ptr Stream) : Stream(std::move(Stream)) {} -GlobalsStream::~GlobalsStream() {} +GlobalsStream::~GlobalsStream() = default; Error GlobalsStream::reload() { StreamReader Reader(*Stream); diff --git a/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp b/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp index 436aa84..b34d770 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp @@ -7,25 +7,24 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/ModInfo.h" - #include "llvm/DebugInfo/MSF/StreamReader.h" -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" +#include "llvm/DebugInfo/PDB/Raw/ModInfo.h" +#include "llvm/DebugInfo/PDB/Raw/RawTypes.h" #include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/MathExtras.h" +#include using namespace llvm; using namespace llvm::msf; using namespace llvm::pdb; using namespace llvm::support; +ModInfo::ModInfo() = default; -ModInfo::ModInfo() : Layout(nullptr) {} - -ModInfo::ModInfo(const ModInfo &Info) - : ModuleName(Info.ModuleName), ObjFileName(Info.ObjFileName), - Layout(Info.Layout) {} +ModInfo::ModInfo(const ModInfo &Info) = default; -ModInfo::~ModInfo() {} +ModInfo::~ModInfo() = default; Error ModInfo::initialize(ReadableStreamRef Stream, ModInfo &Info) { StreamReader Reader(Stream); @@ -77,6 +76,6 @@ uint32_t ModInfo::getRecordLength() const { uint32_t M = ModuleName.str().size() + 1; uint32_t O = ObjFileName.str().size() + 1; uint32_t Size = sizeof(ModuleInfoHeader) + M + O; - Size = llvm::alignTo(Size, 4); + Size = alignTo(Size, 4); return Size; } diff --git a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp index 527ca6b..0ffc5b7 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp @@ -7,13 +7,18 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/ModStream.h" - +#include "llvm/ADT/iterator_range.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/MSF/StreamReader.h" +#include "llvm/DebugInfo/MSF/StreamRef.h" #include "llvm/DebugInfo/PDB/Raw/ModInfo.h" +#include "llvm/DebugInfo/PDB/Raw/ModStream.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h" +#include "llvm/Support/Error.h" +#include +#include using namespace llvm; using namespace llvm::msf; @@ -23,7 +28,7 @@ ModStream::ModStream(const ModInfo &Module, std::unique_ptr Stream) : Mod(Module), Stream(std::move(Stream)) {} -ModStream::~ModStream() {} +ModStream::~ModStream() = default; Error ModStream::reload() { StreamReader Reader(*Stream); @@ -33,8 +38,8 @@ Error ModStream::reload() { uint32_t C13Size = Mod.getC13LineInfoByteSize(); if (C11Size > 0 && C13Size > 0) - return llvm::make_error(raw_error_code::corrupt_file, - "Module has both C11 and C13 line info"); + return make_error(raw_error_code::corrupt_file, + "Module has both C11 and C13 line info"); ReadableStreamRef S; @@ -58,8 +63,8 @@ Error ModStream::reload() { if (auto EC = Reader.readStreamRef(GlobalRefsSubstream, GlobalRefsSize)) return EC; if (Reader.bytesRemaining() > 0) - return llvm::make_error(raw_error_code::corrupt_file, - "Unexpected bytes in module stream."); + return make_error(raw_error_code::corrupt_file, + "Unexpected bytes in module stream."); return Error::success(); } @@ -68,14 +73,13 @@ iterator_range ModStream::symbols(bool *HadError) const { // It's OK if the stream is empty. if (SymbolsSubstream.getUnderlyingStream().getLength() == 0) - return llvm::make_range(SymbolsSubstream.end(), SymbolsSubstream.end()); - return llvm::make_range(SymbolsSubstream.begin(HadError), - SymbolsSubstream.end()); + return make_range(SymbolsSubstream.end(), SymbolsSubstream.end()); + return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end()); } iterator_range ModStream::lines(bool *HadError) const { - return llvm::make_range(LineInfo.begin(HadError), LineInfo.end()); + return make_range(LineInfo.begin(HadError), LineInfo.end()); } Error ModStream::commit() { return Error::success(); } diff --git a/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp b/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp index 40992e9..0f55f58 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp @@ -7,20 +7,24 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/NameMap.h" #include "llvm/ADT/SparseBitVector.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/DebugInfo/MSF/StreamReader.h" -#include "llvm/DebugInfo/MSF/StreamWriter.h" +#include "llvm/DebugInfo/PDB/Raw/NameMap.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" +#include "llvm/Support/Error.h" +#include +#include using namespace llvm; using namespace llvm::msf; using namespace llvm::pdb; -NameMap::NameMap() {} +NameMap::NameMap() = default; Error NameMap::load(StreamReader &Stream) { - // This is some sort of weird string-set/hash table encoded in the stream. // It starts with the number of bytes in the table. uint32_t NumberOfBytes; @@ -146,8 +150,8 @@ Error NameMap::load(StreamReader &Stream) { } iterator_range> NameMap::entries() const { - return llvm::make_range>(Mapping.begin(), - Mapping.end()); + return make_range>(Mapping.begin(), + Mapping.end()); } bool NameMap::tryGetValue(StringRef Name, uint32_t &Value) const { diff --git a/llvm/lib/DebugInfo/PDB/Raw/NameMapBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/NameMapBuilder.cpp index 918a828..f570d59 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/NameMapBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/NameMapBuilder.cpp @@ -7,16 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/NameMapBuilder.h" - +#include "llvm/ADT/STLExtras.h" #include "llvm/DebugInfo/MSF/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/NameMap.h" +#include "llvm/DebugInfo/PDB/Raw/NameMapBuilder.h" #include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include +#include using namespace llvm; using namespace llvm::pdb; -NameMapBuilder::NameMapBuilder() {} +NameMapBuilder::NameMapBuilder() = default; void NameMapBuilder::addMapping(StringRef Name, uint32_t Mapping) { StringDataBytes += Name.size() + 1; diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp index f7bb8ab..b429d21 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp @@ -7,24 +7,27 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" - #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/MSF/MSFCommon.h" #include "llvm/DebugInfo/MSF/StreamArray.h" #include "llvm/DebugInfo/MSF/StreamInterface.h" #include "llvm/DebugInfo/MSF/StreamReader.h" -#include "llvm/DebugInfo/MSF/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/DbiStream.h" #include "llvm/DebugInfo/PDB/Raw/GlobalsStream.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" #include "llvm/DebugInfo/PDB/Raw/NameHashTable.h" +#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/PublicsStream.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/SymbolStream.h" #include "llvm/DebugInfo/PDB/Raw/TpiStream.h" #include "llvm/Support/Endian.h" -#include "llvm/Support/FileOutputBuffer.h" -#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Error.h" +#include +#include +#include using namespace llvm; using namespace llvm::codeview; @@ -33,13 +36,13 @@ using namespace llvm::pdb; namespace { typedef FixedStreamArray ulittle_array; -} +} // end anonymous namespace PDBFile::PDBFile(std::unique_ptr PdbFileBuffer, BumpPtrAllocator &Allocator) : Allocator(Allocator), Buffer(std::move(PdbFileBuffer)) {} -PDBFile::~PDBFile() {} +PDBFile::~PDBFile() = default; uint32_t PDBFile::getBlockSize() const { return ContainerLayout.SB->BlockSize; } @@ -214,7 +217,7 @@ Error PDBFile::parseStreamData() { return Error::success(); } -llvm::ArrayRef PDBFile::getDirectoryBlockArray() const { +ArrayRef PDBFile::getDirectoryBlockArray() const { return ContainerLayout.DirectoryBlocks; } diff --git a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp index 43ac4e5..b31f605 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp @@ -22,29 +22,25 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/PublicsStream.h" - #include "GSI.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/MSF/StreamReader.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" -#include "llvm/DebugInfo/PDB/Raw/RawConstants.h" +#include "llvm/DebugInfo/PDB/Raw/PublicsStream.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/SymbolStream.h" - -#include "llvm/ADT/BitVector.h" #include "llvm/Support/Endian.h" -#include "llvm/Support/Format.h" -#include "llvm/Support/MathExtras.h" +#include "llvm/Support/Error.h" +#include +#include using namespace llvm; using namespace llvm::msf; using namespace llvm::support; using namespace llvm::pdb; - // This is PSGSIHDR struct defined in // https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h struct PublicsStream::HeaderInfo { @@ -62,7 +58,7 @@ PublicsStream::PublicsStream(PDBFile &File, std::unique_ptr Stream) : Pdb(File), Stream(std::move(Stream)) {} -PublicsStream::~PublicsStream() {} +PublicsStream::~PublicsStream() = default; uint32_t PublicsStream::getSymHash() const { return Header->SymHash; } uint32_t PublicsStream::getAddrMap() const { return Header->AddrMap; } @@ -125,7 +121,7 @@ PublicsStream::getSymbols(bool *HadError) const { auto SymbolS = Pdb.getPDBSymbolStream(); if (SymbolS.takeError()) { codeview::CVSymbolArray::Iterator Iter; - return llvm::make_range(Iter, Iter); + return make_range(Iter, Iter); } SymbolStream &SS = SymbolS.get(); diff --git a/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp index ad7a3fc..cd3a206 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp @@ -7,10 +7,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/RawSession.h" - +#include "llvm/ADT/STLExtras.h" #include "llvm/DebugInfo/MSF/ByteStream.h" -#include "llvm/DebugInfo/MSF/StreamInterface.h" #include "llvm/DebugInfo/PDB/GenericError.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBSourceFile.h" @@ -18,9 +16,13 @@ #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" - +#include "llvm/DebugInfo/PDB/Raw/RawSession.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/MemoryBuffer.h" +#include +#include using namespace llvm; using namespace llvm::msf; @@ -30,16 +32,15 @@ RawSession::RawSession(std::unique_ptr PdbFile, std::unique_ptr Allocator) : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)) {} -RawSession::~RawSession() {} +RawSession::~RawSession() = default; Error RawSession::createFromPdb(StringRef Path, std::unique_ptr &Session) { - ErrorOr> ErrorOrBuffer = MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1, /*RequiresNullTerminator=*/false); if (!ErrorOrBuffer) - return llvm::make_error(generic_error_code::invalid_path); + return make_error(generic_error_code::invalid_path); std::unique_ptr Buffer = std::move(*ErrorOrBuffer); auto Stream = llvm::make_unique(std::move(Buffer)); @@ -59,7 +60,7 @@ Error RawSession::createFromPdb(StringRef Path, Error RawSession::createFromExe(StringRef Path, std::unique_ptr &Session) { - return llvm::make_error(raw_error_code::feature_unsupported); + return make_error(raw_error_code::feature_unsupported); } uint64_t RawSession::getLoadAddress() const { return 0; } @@ -92,26 +93,26 @@ RawSession::findLineNumbersByAddress(uint64_t Address, uint32_t Length) const { std::unique_ptr RawSession::findSourceFiles(const PDBSymbolCompiland *Compiland, - llvm::StringRef Pattern, + StringRef Pattern, PDB_NameSearchFlags Flags) const { return nullptr; } std::unique_ptr RawSession::findOneSourceFile(const PDBSymbolCompiland *Compiland, - llvm::StringRef Pattern, + StringRef Pattern, PDB_NameSearchFlags Flags) const { return nullptr; } std::unique_ptr> -RawSession::findCompilandsForSourceFile(llvm::StringRef Pattern, +RawSession::findCompilandsForSourceFile(StringRef Pattern, PDB_NameSearchFlags Flags) const { return nullptr; } std::unique_ptr -RawSession::findOneCompilandForSourceFile(llvm::StringRef Pattern, +RawSession::findOneCompilandForSourceFile(StringRef Pattern, PDB_NameSearchFlags Flags) const { return nullptr; } diff --git a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp index fc5e7ce..a1167cd 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp @@ -7,12 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/TpiStream.h" - +#include "llvm/ADT/iterator_range.h" #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/TypeDeserializer.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" @@ -22,8 +19,12 @@ #include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h" #include "llvm/DebugInfo/PDB/Raw/TpiHashing.h" - +#include "llvm/DebugInfo/PDB/Raw/TpiStream.h" #include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include +#include +#include using namespace llvm; using namespace llvm::codeview; @@ -35,7 +36,7 @@ TpiStream::TpiStream(const PDBFile &File, std::unique_ptr Stream) : Pdb(File), Stream(std::move(Stream)) {} -TpiStream::~TpiStream() {} +TpiStream::~TpiStream() = default; // Verifies that a given type record matches with a given hash value. // Currently we only verify SRC_LINE records. @@ -170,7 +171,7 @@ TpiStream::getHashAdjustments() const { iterator_range TpiStream::types(bool *HadError) const { - return llvm::make_range(TypeRecords.begin(HadError), TypeRecords.end()); + return make_range(TypeRecords.begin(HadError), TypeRecords.end()); } Error TpiStream::commit() { return Error::success(); } diff --git a/llvm/lib/DebugInfo/PDB/Raw/TpiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/TpiStreamBuilder.cpp index aa3547c..c769321 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/TpiStreamBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/TpiStreamBuilder.cpp @@ -1,14 +1,32 @@ -#include "llvm/DebugInfo/PDB/Raw/TpiStreamBuilder.h" - +//===- TpiStreamBuilder.cpp - -------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/MSF/ByteStream.h" #include "llvm/DebugInfo/MSF/MSFBuilder.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/MSF/StreamArray.h" +#include "llvm/DebugInfo/MSF/StreamReader.h" #include "llvm/DebugInfo/MSF/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" +#include "llvm/DebugInfo/PDB/Raw/RawTypes.h" #include "llvm/DebugInfo/PDB/Raw/TpiStream.h" +#include "llvm/DebugInfo/PDB/Raw/TpiStreamBuilder.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include +#include using namespace llvm; using namespace llvm::msf; @@ -19,7 +37,7 @@ TpiStreamBuilder::TpiStreamBuilder(MSFBuilder &Msf, uint32_t StreamIdx) : Msf(Msf), Allocator(Msf.getAllocator()), Header(nullptr), Idx(StreamIdx) { } -TpiStreamBuilder::~TpiStreamBuilder() {} +TpiStreamBuilder::~TpiStreamBuilder() = default; void TpiStreamBuilder::setVersionHeader(PdbRaw_TpiVer Version) { VerHeader = Version; -- 2.7.4