1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[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
This commit is contained in:
Eugene Zelenko 2016-11-23 23:16:32 +00:00
parent a6ebd63f82
commit 290a3cba18
19 changed files with 166 additions and 125 deletions

View File

@ -50,7 +50,7 @@ public:
private: private:
StringRef ModuleName; StringRef ModuleName;
StringRef ObjFileName; StringRef ObjFileName;
const ModuleInfoHeader *Layout; const ModuleInfoHeader *Layout = nullptr;
}; };
struct ModuleInfoEx { struct ModuleInfoEx {

View File

@ -8,6 +8,8 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" #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/Format.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
@ -29,5 +31,4 @@ void DWARFCompileUnit::dump(raw_ostream &OS) {
} }
// VTable anchor. // VTable anchor.
DWARFCompileUnit::~DWARFCompileUnit() { DWARFCompileUnit::~DWARFCompileUnit() = default;
}

View File

@ -37,11 +37,11 @@ using namespace dwarf;
class llvm::FrameEntry { class llvm::FrameEntry {
public: public:
enum FrameKind {FK_CIE, FK_FDE}; enum FrameKind {FK_CIE, FK_FDE};
FrameEntry(FrameKind K, uint64_t Offset, uint64_t Length) FrameEntry(FrameKind K, uint64_t Offset, uint64_t Length)
: Kind(K), Offset(Offset), Length(Length) {} : Kind(K), Offset(Offset), Length(Length) {}
virtual ~FrameEntry() { virtual ~FrameEntry() = default;
}
FrameKind getKind() const { return Kind; } FrameKind getKind() const { return Kind; }
virtual uint64_t getOffset() const { return Offset; } virtual uint64_t getOffset() const { return Offset; }
@ -220,7 +220,7 @@ public:
FDEPointerEncoding(FDEPointerEncoding), FDEPointerEncoding(FDEPointerEncoding),
LSDAPointerEncoding(LSDAPointerEncoding) {} LSDAPointerEncoding(LSDAPointerEncoding) {}
~CIE() override {} ~CIE() override = default;
StringRef getAugmentationString() const { return Augmentation; } StringRef getAugmentationString() const { return Augmentation; }
uint64_t getCodeAlignmentFactor() const { return CodeAlignmentFactor; } uint64_t getCodeAlignmentFactor() const { return CodeAlignmentFactor; }
@ -294,7 +294,7 @@ public:
InitialLocation(InitialLocation), AddressRange(AddressRange), InitialLocation(InitialLocation), AddressRange(AddressRange),
LinkedCIE(Cie) {} LinkedCIE(Cie) {}
~FDE() override {} ~FDE() override = default;
CIE *getLinkedCIE() const { return LinkedCIE; } CIE *getLinkedCIE() const { return LinkedCIE; }
@ -468,8 +468,7 @@ void FrameEntry::dumpInstructions(raw_ostream &OS) const {
DWARFDebugFrame::DWARFDebugFrame(bool IsEH) : IsEH(IsEH) { DWARFDebugFrame::DWARFDebugFrame(bool IsEH) : IsEH(IsEH) {
} }
DWARFDebugFrame::~DWARFDebugFrame() { DWARFDebugFrame::~DWARFDebugFrame() = default;
}
static void LLVM_ATTRIBUTE_UNUSED dumpDataAux(DataExtractor Data, static void LLVM_ATTRIBUTE_UNUSED dumpDataAux(DataExtractor Data,
uint32_t Offset, int Length) { uint32_t Offset, int Length) {
@ -620,12 +619,14 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
} }
} }
auto Cie = make_unique<CIE>(StartOffset, Length, Version, auto Cie = llvm::make_unique<CIE>(StartOffset, Length, Version,
AugmentationString, AddressSize, AugmentationString, AddressSize,
SegmentDescriptorSize, CodeAlignmentFactor, SegmentDescriptorSize,
DataAlignmentFactor, ReturnAddressRegister, CodeAlignmentFactor,
AugmentationData, FDEPointerEncoding, DataAlignmentFactor,
LSDAPointerEncoding); ReturnAddressRegister,
AugmentationData, FDEPointerEncoding,
LSDAPointerEncoding);
CIEs[StartOffset] = Cie.get(); CIEs[StartOffset] = Cie.get();
Entries.emplace_back(std::move(Cie)); Entries.emplace_back(std::move(Cie));
} else { } else {

View File

@ -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/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
#include "llvm/Support/Dwarf.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 "llvm/Support/Path.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdio> #include <cstdio>
#include <vector>
namespace llvm { namespace llvm {
using namespace dwarf; using namespace dwarf;
void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) { void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) {
@ -49,8 +60,7 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
clear(); clear();
} }
DWARFUnit::~DWARFUnit() { DWARFUnit::~DWARFUnit() = default;
}
bool DWARFUnit::getAddrOffsetSectionItem(uint32_t Index, bool DWARFUnit::getAddrOffsetSectionItem(uint32_t Index,
uint64_t &Result) const { uint64_t &Result) const {
@ -121,7 +131,7 @@ bool DWARFUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
bool DWARFUnit::extractRangeList(uint32_t RangeListOffset, bool DWARFUnit::extractRangeList(uint32_t RangeListOffset,
DWARFDebugRangeList &RangeList) const { DWARFDebugRangeList &RangeList) const {
// Require that compile unit is extracted. // Require that compile unit is extracted.
assert(DieArray.size() > 0); assert(!DieArray.empty());
DataExtractor RangesData(RangeSection, isLittleEndian, AddrSize); DataExtractor RangesData(RangeSection, isLittleEndian, AddrSize);
uint32_t ActualRangeListOffset = RangeSectionBase + RangeListOffset; uint32_t ActualRangeListOffset = RangeSectionBase + RangeListOffset;
return RangeList.extract(RangesData, &ActualRangeListOffset); return RangeList.extract(RangesData, &ActualRangeListOffset);
@ -238,11 +248,11 @@ void DWARFUnit::extractDIEsToVector(
} }
size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) { size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
if ((CUDieOnly && DieArray.size() > 0) || if ((CUDieOnly && !DieArray.empty()) ||
DieArray.size() > 1) DieArray.size() > 1)
return 0; // Already parsed. return 0; // Already parsed.
bool HasCUDie = DieArray.size() > 0; bool HasCUDie = !DieArray.empty();
extractDIEsToVector(!HasCUDie, !CUDieOnly, DieArray); extractDIEsToVector(!HasCUDie, !CUDieOnly, DieArray);
if (DieArray.empty()) if (DieArray.empty())
@ -268,7 +278,7 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
} }
DWARFUnit::DWOHolder::DWOHolder(StringRef DWOPath) DWARFUnit::DWOHolder::DWOHolder(StringRef DWOPath)
: DWOFile(), DWOContext(), DWOU(nullptr) { : DWOU(nullptr) {
auto Obj = object::ObjectFile::createObjectFile(DWOPath); auto Obj = object::ObjectFile::createObjectFile(DWOPath);
if (!Obj) { if (!Obj) {
// TODO: Actually report errors helpfully. // TODO: Actually report errors helpfully.
@ -404,4 +414,5 @@ const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
assert(Kind == DW_SECT_TYPES); assert(Kind == DW_SECT_TYPES);
return Context.getTUIndex(); return Context.getTUIndex();
} }
}
} // end namespace llvm

View File

@ -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 // The LLVM Compiler Infrastructure
// //
@ -8,15 +8,17 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" #include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h" #include "llvm/DebugInfo/PDB/PDBExtras.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <cstdint>
#include <string>
using namespace llvm; using namespace llvm;
using namespace llvm::pdb; using namespace llvm::pdb;
IPDBSourceFile::~IPDBSourceFile() {} IPDBSourceFile::~IPDBSourceFile() = default;
void IPDBSourceFile::dump(raw_ostream &OS, int Indent) const { void IPDBSourceFile::dump(raw_ostream &OS, int Indent) const {
OS.indent(Indent); OS.indent(Indent);

View File

@ -15,15 +15,14 @@
#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" #include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h" #include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
using namespace llvm; using namespace llvm;
using namespace llvm::pdb; using namespace llvm::pdb;
IPDBSession::~IPDBSession() {} IPDBSession::~IPDBSession() = default;
IPDBDataStream::~IPDBDataStream() {} IPDBDataStream::~IPDBDataStream() = default;
IPDBRawSymbol::~IPDBRawSymbol() {} IPDBRawSymbol::~IPDBRawSymbol() = default;
IPDBLineNumber::~IPDBLineNumber() {} IPDBLineNumber::~IPDBLineNumber() = default;

View File

@ -20,7 +20,7 @@ using namespace llvm::pdb;
PDBSymDumper::PDBSymDumper(bool ShouldRequireImpl) PDBSymDumper::PDBSymDumper(bool ShouldRequireImpl)
: RequireImpl(ShouldRequireImpl) {} : RequireImpl(ShouldRequireImpl) {}
PDBSymDumper::~PDBSymDumper() {} PDBSymDumper::~PDBSymDumper() = default;
void PDBSymDumper::dump(const PDBSymbolAnnotation &Symbol) { void PDBSymDumper::dump(const PDBSymbolAnnotation &Symbol) {
PDB_SYMDUMP_UNREACHABLE(PDBSymbolAnnotation) PDB_SYMDUMP_UNREACHABLE(PDBSymbolAnnotation)

View File

@ -8,9 +8,9 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/PDBSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h"
#include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h" #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h"
#include "llvm/DebugInfo/PDB/PDBSymbolBlock.h" #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
@ -42,12 +42,9 @@
#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h" #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h"
#include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h" #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
#include "llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h" #include "llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h"
#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include "llvm/DebugInfo/PDB/PDBTypes.h"
#include <algorithm>
#include <memory> #include <memory>
#include <utility>
#include <memory>
#include <utility>
using namespace llvm; using namespace llvm;
using namespace llvm::pdb; using namespace llvm::pdb;
@ -56,7 +53,7 @@ PDBSymbol::PDBSymbol(const IPDBSession &PDBSession,
std::unique_ptr<IPDBRawSymbol> Symbol) std::unique_ptr<IPDBRawSymbol> Symbol)
: Session(PDBSession), RawSymbol(std::move(Symbol)) {} : Session(PDBSession), RawSymbol(std::move(Symbol)) {}
PDBSymbol::~PDBSymbol() {} PDBSymbol::~PDBSymbol() = default;
#define FACTORY_SYMTAG_CASE(Tag, Type) \ #define FACTORY_SYMTAG_CASE(Tag, Type) \
case PDB_SymType::Tag: \ case PDB_SymType::Tag: \

View File

@ -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/StreamArray.h"
#include "llvm/DebugInfo/MSF/StreamReader.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/ISectionContribVisitor.h"
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h" #include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
@ -21,6 +22,10 @@
#include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h"
#include "llvm/DebugInfo/PDB/Raw/RawTypes.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
#include "llvm/Object/COFF.h" #include "llvm/Object/COFF.h"
#include "llvm/Support/Error.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
using namespace llvm; using namespace llvm;
using namespace llvm::codeview; using namespace llvm::codeview;
@ -46,7 +51,7 @@ DbiStream::DbiStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream)
: Pdb(File), Stream(std::move(Stream)), Header(nullptr) { : Pdb(File), Stream(std::move(Stream)), Header(nullptr) {
} }
DbiStream::~DbiStream() {} DbiStream::~DbiStream() = default;
Error DbiStream::reload() { Error DbiStream::reload() {
StreamReader Reader(*Stream); StreamReader Reader(*Stream);
@ -217,7 +222,7 @@ msf::FixedStreamArray<SecMapEntry> DbiStream::getSectionMap() const {
return SectionMap; return SectionMap;
} }
void llvm::pdb::DbiStream::visitSectionContributions( void DbiStream::visitSectionContributions(
ISectionContribVisitor &Visitor) const { ISectionContribVisitor &Visitor) const {
if (SectionContribVersion == DbiSecContribVer60) { if (SectionContribVersion == DbiSecContribVer60) {
for (auto &SC : SectionContribs) for (auto &SC : SectionContribs)

View File

@ -7,15 +7,11 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/Raw/GlobalsStream.h"
#include "GSI.h" #include "GSI.h"
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/MSF/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/GlobalsStream.h"
#include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h" #include "llvm/Support/Error.h"
#include <algorithm>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;
@ -24,7 +20,7 @@ using namespace llvm::pdb;
GlobalsStream::GlobalsStream(std::unique_ptr<MappedBlockStream> Stream) GlobalsStream::GlobalsStream(std::unique_ptr<MappedBlockStream> Stream)
: Stream(std::move(Stream)) {} : Stream(std::move(Stream)) {}
GlobalsStream::~GlobalsStream() {} GlobalsStream::~GlobalsStream() = default;
Error GlobalsStream::reload() { Error GlobalsStream::reload() {
StreamReader Reader(*Stream); StreamReader Reader(*Stream);

View File

@ -7,25 +7,24 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
#include "llvm/DebugInfo/MSF/StreamReader.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/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MathExtras.h"
#include <cstdint>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;
using namespace llvm::pdb; using namespace llvm::pdb;
using namespace llvm::support; using namespace llvm::support;
ModInfo::ModInfo() = default;
ModInfo::ModInfo() : Layout(nullptr) {} ModInfo::ModInfo(const ModInfo &Info) = default;
ModInfo::ModInfo(const ModInfo &Info) ModInfo::~ModInfo() = default;
: ModuleName(Info.ModuleName), ObjFileName(Info.ObjFileName),
Layout(Info.Layout) {}
ModInfo::~ModInfo() {}
Error ModInfo::initialize(ReadableStreamRef Stream, ModInfo &Info) { Error ModInfo::initialize(ReadableStreamRef Stream, ModInfo &Info) {
StreamReader Reader(Stream); StreamReader Reader(Stream);
@ -77,6 +76,6 @@ uint32_t ModInfo::getRecordLength() const {
uint32_t M = ModuleName.str().size() + 1; uint32_t M = ModuleName.str().size() + 1;
uint32_t O = ObjFileName.str().size() + 1; uint32_t O = ObjFileName.str().size() + 1;
uint32_t Size = sizeof(ModuleInfoHeader) + M + O; uint32_t Size = sizeof(ModuleInfoHeader) + M + O;
Size = llvm::alignTo(Size, 4); Size = alignTo(Size, 4);
return Size; return Size;
} }

View File

@ -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/StreamReader.h"
#include "llvm/DebugInfo/MSF/StreamRef.h"
#include "llvm/DebugInfo/PDB/Raw/ModInfo.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/PDBFile.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h"
#include "llvm/DebugInfo/PDB/Raw/RawTypes.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
#include "llvm/Support/Error.h"
#include <algorithm>
#include <cstdint>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;
@ -23,7 +28,7 @@ ModStream::ModStream(const ModInfo &Module,
std::unique_ptr<MappedBlockStream> Stream) std::unique_ptr<MappedBlockStream> Stream)
: Mod(Module), Stream(std::move(Stream)) {} : Mod(Module), Stream(std::move(Stream)) {}
ModStream::~ModStream() {} ModStream::~ModStream() = default;
Error ModStream::reload() { Error ModStream::reload() {
StreamReader Reader(*Stream); StreamReader Reader(*Stream);
@ -33,8 +38,8 @@ Error ModStream::reload() {
uint32_t C13Size = Mod.getC13LineInfoByteSize(); uint32_t C13Size = Mod.getC13LineInfoByteSize();
if (C11Size > 0 && C13Size > 0) if (C11Size > 0 && C13Size > 0)
return llvm::make_error<RawError>(raw_error_code::corrupt_file, return make_error<RawError>(raw_error_code::corrupt_file,
"Module has both C11 and C13 line info"); "Module has both C11 and C13 line info");
ReadableStreamRef S; ReadableStreamRef S;
@ -58,8 +63,8 @@ Error ModStream::reload() {
if (auto EC = Reader.readStreamRef(GlobalRefsSubstream, GlobalRefsSize)) if (auto EC = Reader.readStreamRef(GlobalRefsSubstream, GlobalRefsSize))
return EC; return EC;
if (Reader.bytesRemaining() > 0) if (Reader.bytesRemaining() > 0)
return llvm::make_error<RawError>(raw_error_code::corrupt_file, return make_error<RawError>(raw_error_code::corrupt_file,
"Unexpected bytes in module stream."); "Unexpected bytes in module stream.");
return Error::success(); return Error::success();
} }
@ -68,14 +73,13 @@ iterator_range<codeview::CVSymbolArray::Iterator>
ModStream::symbols(bool *HadError) const { ModStream::symbols(bool *HadError) const {
// It's OK if the stream is empty. // It's OK if the stream is empty.
if (SymbolsSubstream.getUnderlyingStream().getLength() == 0) if (SymbolsSubstream.getUnderlyingStream().getLength() == 0)
return llvm::make_range(SymbolsSubstream.end(), SymbolsSubstream.end()); return make_range(SymbolsSubstream.end(), SymbolsSubstream.end());
return llvm::make_range(SymbolsSubstream.begin(HadError), return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end());
SymbolsSubstream.end());
} }
iterator_range<codeview::ModuleSubstreamArray::Iterator> iterator_range<codeview::ModuleSubstreamArray::Iterator>
ModStream::lines(bool *HadError) const { 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(); } Error ModStream::commit() { return Error::success(); }

View File

@ -7,20 +7,24 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/Raw/NameMap.h"
#include "llvm/ADT/SparseBitVector.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/StreamReader.h"
#include "llvm/DebugInfo/MSF/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/NameMap.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h"
#include "llvm/Support/Error.h"
#include <algorithm>
#include <cstdint>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;
using namespace llvm::pdb; using namespace llvm::pdb;
NameMap::NameMap() {} NameMap::NameMap() = default;
Error NameMap::load(StreamReader &Stream) { Error NameMap::load(StreamReader &Stream) {
// This is some sort of weird string-set/hash table encoded in the 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. // It starts with the number of bytes in the table.
uint32_t NumberOfBytes; uint32_t NumberOfBytes;
@ -146,8 +150,8 @@ Error NameMap::load(StreamReader &Stream) {
} }
iterator_range<StringMapConstIterator<uint32_t>> NameMap::entries() const { iterator_range<StringMapConstIterator<uint32_t>> NameMap::entries() const {
return llvm::make_range<StringMapConstIterator<uint32_t>>(Mapping.begin(), return make_range<StringMapConstIterator<uint32_t>>(Mapping.begin(),
Mapping.end()); Mapping.end());
} }
bool NameMap::tryGetValue(StringRef Name, uint32_t &Value) const { bool NameMap::tryGetValue(StringRef Name, uint32_t &Value) const {

View File

@ -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/MSF/StreamWriter.h"
#include "llvm/DebugInfo/PDB/Raw/NameMap.h" #include "llvm/DebugInfo/PDB/Raw/NameMap.h"
#include "llvm/DebugInfo/PDB/Raw/NameMapBuilder.h"
#include "llvm/Support/Endian.h" #include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include <algorithm>
#include <cstdint>
using namespace llvm; using namespace llvm;
using namespace llvm::pdb; using namespace llvm::pdb;
NameMapBuilder::NameMapBuilder() {} NameMapBuilder::NameMapBuilder() = default;
void NameMapBuilder::addMapping(StringRef Name, uint32_t Mapping) { void NameMapBuilder::addMapping(StringRef Name, uint32_t Mapping) {
StringDataBytes += Name.size() + 1; StringDataBytes += Name.size() + 1;

View File

@ -7,24 +7,27 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
#include "llvm/ADT/ArrayRef.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/StreamArray.h"
#include "llvm/DebugInfo/MSF/StreamInterface.h" #include "llvm/DebugInfo/MSF/StreamInterface.h"
#include "llvm/DebugInfo/MSF/StreamReader.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/DbiStream.h"
#include "llvm/DebugInfo/PDB/Raw/GlobalsStream.h" #include "llvm/DebugInfo/PDB/Raw/GlobalsStream.h"
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
#include "llvm/DebugInfo/PDB/Raw/NameHashTable.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/PublicsStream.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h"
#include "llvm/DebugInfo/PDB/Raw/SymbolStream.h" #include "llvm/DebugInfo/PDB/Raw/SymbolStream.h"
#include "llvm/DebugInfo/PDB/Raw/TpiStream.h" #include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
#include "llvm/Support/Endian.h" #include "llvm/Support/Endian.h"
#include "llvm/Support/FileOutputBuffer.h" #include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h" #include <algorithm>
#include <cassert>
#include <cstdint>
using namespace llvm; using namespace llvm;
using namespace llvm::codeview; using namespace llvm::codeview;
@ -33,13 +36,13 @@ using namespace llvm::pdb;
namespace { namespace {
typedef FixedStreamArray<support::ulittle32_t> ulittle_array; typedef FixedStreamArray<support::ulittle32_t> ulittle_array;
} } // end anonymous namespace
PDBFile::PDBFile(std::unique_ptr<ReadableStream> PdbFileBuffer, PDBFile::PDBFile(std::unique_ptr<ReadableStream> PdbFileBuffer,
BumpPtrAllocator &Allocator) BumpPtrAllocator &Allocator)
: Allocator(Allocator), Buffer(std::move(PdbFileBuffer)) {} : Allocator(Allocator), Buffer(std::move(PdbFileBuffer)) {}
PDBFile::~PDBFile() {} PDBFile::~PDBFile() = default;
uint32_t PDBFile::getBlockSize() const { return ContainerLayout.SB->BlockSize; } uint32_t PDBFile::getBlockSize() const { return ContainerLayout.SB->BlockSize; }
@ -214,7 +217,7 @@ Error PDBFile::parseStreamData() {
return Error::success(); return Error::success();
} }
llvm::ArrayRef<support::ulittle32_t> PDBFile::getDirectoryBlockArray() const { ArrayRef<support::ulittle32_t> PDBFile::getDirectoryBlockArray() const {
return ContainerLayout.DirectoryBlocks; return ContainerLayout.DirectoryBlocks;
} }

View File

@ -22,29 +22,25 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/Raw/PublicsStream.h"
#include "GSI.h" #include "GSI.h"
#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/ADT/iterator_range.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/MSF/StreamReader.h" #include "llvm/DebugInfo/MSF/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/PDBFile.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/RawError.h"
#include "llvm/DebugInfo/PDB/Raw/SymbolStream.h" #include "llvm/DebugInfo/PDB/Raw/SymbolStream.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/Support/Endian.h" #include "llvm/Support/Endian.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Error.h"
#include "llvm/Support/MathExtras.h" #include <algorithm>
#include <cstdint>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;
using namespace llvm::support; using namespace llvm::support;
using namespace llvm::pdb; using namespace llvm::pdb;
// This is PSGSIHDR struct defined in // This is PSGSIHDR struct defined in
// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h // https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
struct PublicsStream::HeaderInfo { struct PublicsStream::HeaderInfo {
@ -62,7 +58,7 @@ PublicsStream::PublicsStream(PDBFile &File,
std::unique_ptr<MappedBlockStream> Stream) std::unique_ptr<MappedBlockStream> Stream)
: Pdb(File), Stream(std::move(Stream)) {} : Pdb(File), Stream(std::move(Stream)) {}
PublicsStream::~PublicsStream() {} PublicsStream::~PublicsStream() = default;
uint32_t PublicsStream::getSymHash() const { return Header->SymHash; } uint32_t PublicsStream::getSymHash() const { return Header->SymHash; }
uint32_t PublicsStream::getAddrMap() const { return Header->AddrMap; } uint32_t PublicsStream::getAddrMap() const { return Header->AddrMap; }
@ -125,7 +121,7 @@ PublicsStream::getSymbols(bool *HadError) const {
auto SymbolS = Pdb.getPDBSymbolStream(); auto SymbolS = Pdb.getPDBSymbolStream();
if (SymbolS.takeError()) { if (SymbolS.takeError()) {
codeview::CVSymbolArray::Iterator Iter; codeview::CVSymbolArray::Iterator Iter;
return llvm::make_range(Iter, Iter); return make_range(Iter, Iter);
} }
SymbolStream &SS = SymbolS.get(); SymbolStream &SS = SymbolS.get();

View File

@ -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/ByteStream.h"
#include "llvm/DebugInfo/MSF/StreamInterface.h"
#include "llvm/DebugInfo/PDB/GenericError.h" #include "llvm/DebugInfo/PDB/GenericError.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" #include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
@ -18,9 +16,13 @@
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h" #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.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/ErrorOr.h"
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
#include <algorithm>
#include <memory>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;
@ -30,16 +32,15 @@ RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile,
std::unique_ptr<BumpPtrAllocator> Allocator) std::unique_ptr<BumpPtrAllocator> Allocator)
: Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)) {} : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)) {}
RawSession::~RawSession() {} RawSession::~RawSession() = default;
Error RawSession::createFromPdb(StringRef Path, Error RawSession::createFromPdb(StringRef Path,
std::unique_ptr<IPDBSession> &Session) { std::unique_ptr<IPDBSession> &Session) {
ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer = ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1, MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
/*RequiresNullTerminator=*/false); /*RequiresNullTerminator=*/false);
if (!ErrorOrBuffer) if (!ErrorOrBuffer)
return llvm::make_error<GenericError>(generic_error_code::invalid_path); return make_error<GenericError>(generic_error_code::invalid_path);
std::unique_ptr<MemoryBuffer> Buffer = std::move(*ErrorOrBuffer); std::unique_ptr<MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
auto Stream = llvm::make_unique<MemoryBufferByteStream>(std::move(Buffer)); auto Stream = llvm::make_unique<MemoryBufferByteStream>(std::move(Buffer));
@ -59,7 +60,7 @@ Error RawSession::createFromPdb(StringRef Path,
Error RawSession::createFromExe(StringRef Path, Error RawSession::createFromExe(StringRef Path,
std::unique_ptr<IPDBSession> &Session) { std::unique_ptr<IPDBSession> &Session) {
return llvm::make_error<RawError>(raw_error_code::feature_unsupported); return make_error<RawError>(raw_error_code::feature_unsupported);
} }
uint64_t RawSession::getLoadAddress() const { return 0; } uint64_t RawSession::getLoadAddress() const { return 0; }
@ -92,26 +93,26 @@ RawSession::findLineNumbersByAddress(uint64_t Address, uint32_t Length) const {
std::unique_ptr<IPDBEnumSourceFiles> std::unique_ptr<IPDBEnumSourceFiles>
RawSession::findSourceFiles(const PDBSymbolCompiland *Compiland, RawSession::findSourceFiles(const PDBSymbolCompiland *Compiland,
llvm::StringRef Pattern, StringRef Pattern,
PDB_NameSearchFlags Flags) const { PDB_NameSearchFlags Flags) const {
return nullptr; return nullptr;
} }
std::unique_ptr<IPDBSourceFile> std::unique_ptr<IPDBSourceFile>
RawSession::findOneSourceFile(const PDBSymbolCompiland *Compiland, RawSession::findOneSourceFile(const PDBSymbolCompiland *Compiland,
llvm::StringRef Pattern, StringRef Pattern,
PDB_NameSearchFlags Flags) const { PDB_NameSearchFlags Flags) const {
return nullptr; return nullptr;
} }
std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
RawSession::findCompilandsForSourceFile(llvm::StringRef Pattern, RawSession::findCompilandsForSourceFile(StringRef Pattern,
PDB_NameSearchFlags Flags) const { PDB_NameSearchFlags Flags) const {
return nullptr; return nullptr;
} }
std::unique_ptr<PDBSymbolCompiland> std::unique_ptr<PDBSymbolCompiland>
RawSession::findOneCompilandForSourceFile(llvm::StringRef Pattern, RawSession::findOneCompilandForSourceFile(StringRef Pattern,
PDB_NameSearchFlags Flags) const { PDB_NameSearchFlags Flags) const {
return nullptr; return nullptr;
} }

View File

@ -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/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h" #include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
@ -22,8 +19,12 @@
#include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h"
#include "llvm/DebugInfo/PDB/Raw/RawTypes.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
#include "llvm/DebugInfo/PDB/Raw/TpiHashing.h" #include "llvm/DebugInfo/PDB/Raw/TpiHashing.h"
#include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
#include "llvm/Support/Endian.h" #include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include <algorithm>
#include <cstdint>
#include <vector>
using namespace llvm; using namespace llvm;
using namespace llvm::codeview; using namespace llvm::codeview;
@ -35,7 +36,7 @@ TpiStream::TpiStream(const PDBFile &File,
std::unique_ptr<MappedBlockStream> Stream) std::unique_ptr<MappedBlockStream> Stream)
: Pdb(File), Stream(std::move(Stream)) {} : Pdb(File), Stream(std::move(Stream)) {}
TpiStream::~TpiStream() {} TpiStream::~TpiStream() = default;
// Verifies that a given type record matches with a given hash value. // Verifies that a given type record matches with a given hash value.
// Currently we only verify SRC_LINE records. // Currently we only verify SRC_LINE records.
@ -170,7 +171,7 @@ TpiStream::getHashAdjustments() const {
iterator_range<CVTypeArray::Iterator> iterator_range<CVTypeArray::Iterator>
TpiStream::types(bool *HadError) const { 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(); } Error TpiStream::commit() { return Error::success(); }

View File

@ -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/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/MSF/ByteStream.h"
#include "llvm/DebugInfo/MSF/MSFBuilder.h" #include "llvm/DebugInfo/MSF/MSFBuilder.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.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/MSF/StreamWriter.h"
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.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/TpiStream.h"
#include "llvm/DebugInfo/PDB/Raw/TpiStreamBuilder.h"
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include <algorithm>
#include <cstdint>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;
@ -19,7 +37,7 @@ TpiStreamBuilder::TpiStreamBuilder(MSFBuilder &Msf, uint32_t StreamIdx)
: Msf(Msf), Allocator(Msf.getAllocator()), Header(nullptr), Idx(StreamIdx) { : Msf(Msf), Allocator(Msf.getAllocator()), Header(nullptr), Idx(StreamIdx) {
} }
TpiStreamBuilder::~TpiStreamBuilder() {} TpiStreamBuilder::~TpiStreamBuilder() = default;
void TpiStreamBuilder::setVersionHeader(PdbRaw_TpiVer Version) { void TpiStreamBuilder::setVersionHeader(PdbRaw_TpiVer Version) {
VerHeader = Version; VerHeader = Version;