diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h b/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h index b28f3fbef8c..98e6a54cf82 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h +++ b/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h @@ -1,4 +1,4 @@ -//===- ModuleDebugLineFragment.h --------------------------------*- C++ -*-===// +//===- ModuleDebugFileChecksumFragment.h ------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -39,15 +39,15 @@ public: namespace llvm { namespace codeview { -class ModuleDebugFileChecksumFragment final : public ModuleDebugFragment { - typedef VarStreamArray FileChecksumArray; +class ModuleDebugFileChecksumFragmentRef final : public ModuleDebugFragmentRef { + typedef VarStreamArray FileChecksumArray; typedef FileChecksumArray::Iterator Iterator; public: - ModuleDebugFileChecksumFragment() - : ModuleDebugFragment(ModuleDebugFragmentKind::FileChecksums) {} + ModuleDebugFileChecksumFragmentRef() + : ModuleDebugFragmentRef(ModuleDebugFragmentKind::FileChecksums) {} - static bool classof(const ModuleDebugFragment *S) { + static bool classof(const ModuleDebugFragmentRef *S) { return S->kind() == ModuleDebugFragmentKind::FileChecksums; } diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h b/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h index 98d587f6521..f8b60c094ce 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h +++ b/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h @@ -16,11 +16,11 @@ namespace llvm { namespace codeview { -class ModuleDebugFragment { +class ModuleDebugFragmentRef { public: - explicit ModuleDebugFragment(ModuleDebugFragmentKind Kind) : Kind(Kind) {} + explicit ModuleDebugFragmentRef(ModuleDebugFragmentKind Kind) : Kind(Kind) {} + virtual ~ModuleDebugFragmentRef(); - virtual ~ModuleDebugFragment(); ModuleDebugFragmentKind kind() const { return Kind; } protected: diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h b/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h index bcde565f6de..90da3e03a15 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h +++ b/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h @@ -17,24 +17,25 @@ namespace llvm { namespace codeview { -class ModuleDebugFileChecksumFragment; +class ModuleDebugFileChecksumFragmentRef; class ModuleDebugFragmentRecord; -class ModuleDebugInlineeLineFragment; -class ModuleDebugLineFragment; -class ModuleDebugUnknownFragment; +class ModuleDebugInlineeLineFragmentRef; +class ModuleDebugLineFragmentRef; +class ModuleDebugUnknownFragmentRef; class ModuleDebugFragmentVisitor { public: virtual ~ModuleDebugFragmentVisitor() = default; - virtual Error visitUnknown(ModuleDebugUnknownFragment &Unknown) { + virtual Error visitUnknown(ModuleDebugUnknownFragmentRef &Unknown) { return Error::success(); } - virtual Error visitLines(ModuleDebugLineFragment &Lines) { + virtual Error visitLines(ModuleDebugLineFragmentRef &Lines) { return Error::success(); } - virtual Error visitFileChecksums(ModuleDebugFileChecksumFragment &Checksums) { + virtual Error + visitFileChecksums(ModuleDebugFileChecksumFragmentRef &Checksums) { return Error::success(); } diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h b/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h index 8b6ae6408a9..6268349d21b 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h +++ b/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h @@ -63,15 +63,15 @@ public: LineColumnEntry &Item, const LineFragmentHeader *Header); }; -class ModuleDebugLineFragment final : public ModuleDebugFragment { +class ModuleDebugLineFragmentRef final : public ModuleDebugFragmentRef { friend class LineColumnExtractor; typedef VarStreamArray LineInfoArray; typedef LineInfoArray::Iterator Iterator; public: - ModuleDebugLineFragment(); + ModuleDebugLineFragmentRef(); - static bool classof(const ModuleDebugFragment *S) { + static bool classof(const ModuleDebugFragmentRef *S) { return S->kind() == ModuleDebugFragmentKind::Lines; } diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h b/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h index bb764b6ea66..b8c1c02e5cf 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h +++ b/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h @@ -16,10 +16,11 @@ namespace llvm { namespace codeview { -class ModuleDebugUnknownFragment final : public ModuleDebugFragment { +class ModuleDebugUnknownFragmentRef final : public ModuleDebugFragmentRef { public: - ModuleDebugUnknownFragment(ModuleDebugFragmentKind Kind, BinaryStreamRef Data) - : ModuleDebugFragment(Kind), Data(Data) {} + ModuleDebugUnknownFragmentRef(ModuleDebugFragmentKind Kind, + BinaryStreamRef Data) + : ModuleDebugFragmentRef(Kind), Data(Data) {} BinaryStreamRef getData() const { return Data; } diff --git a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h index 2093691c453..2c95690ed58 100644 --- a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h +++ b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h @@ -24,14 +24,14 @@ namespace pdb { class PDBFile; class DbiModuleDescriptor; -class ModuleDebugStream { +class ModuleDebugStreamRef { typedef codeview::ModuleDebugFragmentArray::Iterator LinesAndChecksumsIterator; public: - ModuleDebugStream(const DbiModuleDescriptor &Module, - std::unique_ptr Stream); - ~ModuleDebugStream(); + ModuleDebugStreamRef(const DbiModuleDescriptor &Module, + std::unique_ptr Stream); + ~ModuleDebugStreamRef(); Error reload(); @@ -54,7 +54,7 @@ private: std::unique_ptr Stream; codeview::CVSymbolArray SymbolsSubstream; - BinaryStreamRef LinesSubstream; + BinaryStreamRef C11LinesSubstream; BinaryStreamRef C13LinesSubstream; BinaryStreamRef GlobalRefsSubstream; diff --git a/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp b/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp index 3f234adc1c2..4bbfe285423 100644 --- a/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp +++ b/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp @@ -41,7 +41,8 @@ Error llvm::VarStreamArrayExtractor::extract( return Error::success(); } -Error ModuleDebugFileChecksumFragment::initialize(BinaryStreamReader Reader) { +Error ModuleDebugFileChecksumFragmentRef::initialize( + BinaryStreamReader Reader) { if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining())) return EC; diff --git a/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp b/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp index a3327b06b98..36f86cbbdf6 100644 --- a/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp +++ b/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp @@ -11,4 +11,4 @@ using namespace llvm::codeview; -ModuleDebugFragment::~ModuleDebugFragment() {} +ModuleDebugFragmentRef::~ModuleDebugFragmentRef() {} diff --git a/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp b/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp index ce1d8d918b2..b7a86ee6699 100644 --- a/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp +++ b/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp @@ -24,21 +24,21 @@ Error llvm::codeview::visitModuleDebugFragment( BinaryStreamReader Reader(R.getRecordData()); switch (R.kind()) { case ModuleDebugFragmentKind::Lines: { - ModuleDebugLineFragment Fragment; + ModuleDebugLineFragmentRef Fragment; if (auto EC = Fragment.initialize(Reader)) return EC; return V.visitLines(Fragment); } case ModuleDebugFragmentKind::FileChecksums: { - ModuleDebugFileChecksumFragment Fragment; + ModuleDebugFileChecksumFragmentRef Fragment; if (auto EC = Fragment.initialize(Reader)) return EC; return V.visitFileChecksums(Fragment); } default: { - ModuleDebugUnknownFragment Fragment(R.kind(), R.getRecordData()); + ModuleDebugUnknownFragmentRef Fragment(R.kind(), R.getRecordData()); return V.visitUnknown(Fragment); } } diff --git a/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp b/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp index d25be2d02d8..6a9751c1257 100644 --- a/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp +++ b/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp @@ -47,10 +47,10 @@ Error LineColumnExtractor::extract(BinaryStreamRef Stream, uint32_t &Len, return Error::success(); } -ModuleDebugLineFragment::ModuleDebugLineFragment() - : ModuleDebugFragment(ModuleDebugFragmentKind::Lines) {} +ModuleDebugLineFragmentRef::ModuleDebugLineFragmentRef() + : ModuleDebugFragmentRef(ModuleDebugFragmentKind::Lines) {} -Error ModuleDebugLineFragment::initialize(BinaryStreamReader Reader) { +Error ModuleDebugLineFragmentRef::initialize(BinaryStreamReader Reader) { if (auto EC = Reader.readObject(Header)) return EC; @@ -61,6 +61,6 @@ Error ModuleDebugLineFragment::initialize(BinaryStreamReader Reader) { return Error::success(); } -bool ModuleDebugLineFragment::hasColumnInfo() const { - return Header->Flags & LF_HaveColumns; +bool ModuleDebugLineFragmentRef::hasColumnInfo() const { + return !!(Header->Flags & LF_HaveColumns); } diff --git a/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp b/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp index 5e719c6179a..d7a203746a0 100644 --- a/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp +++ b/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp @@ -25,13 +25,14 @@ using namespace llvm::codeview; using namespace llvm::msf; using namespace llvm::pdb; -ModuleDebugStream::ModuleDebugStream(const DbiModuleDescriptor &Module, - std::unique_ptr Stream) +ModuleDebugStreamRef::ModuleDebugStreamRef( + const DbiModuleDescriptor &Module, + std::unique_ptr Stream) : Mod(Module), Stream(std::move(Stream)) {} -ModuleDebugStream::~ModuleDebugStream() = default; +ModuleDebugStreamRef::~ModuleDebugStreamRef() = default; -Error ModuleDebugStream::reload() { +Error ModuleDebugStreamRef::reload() { BinaryStreamReader Reader(*Stream); uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize(); @@ -49,7 +50,7 @@ Error ModuleDebugStream::reload() { if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4)) return EC; - if (auto EC = Reader.readStreamRef(LinesSubstream, C11Size)) + if (auto EC = Reader.readStreamRef(C11LinesSubstream, C11Size)) return EC; if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size)) return EC; @@ -72,17 +73,17 @@ Error ModuleDebugStream::reload() { } iterator_range -ModuleDebugStream::symbols(bool *HadError) const { +ModuleDebugStreamRef::symbols(bool *HadError) const { return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end()); } -llvm::iterator_range -ModuleDebugStream::linesAndChecksums() const { +llvm::iterator_range +ModuleDebugStreamRef::linesAndChecksums() const { return make_range(LinesAndChecksums.begin(), LinesAndChecksums.end()); } -bool ModuleDebugStream::hasLineInfo() const { +bool ModuleDebugStreamRef::hasLineInfo() const { return C13LinesSubstream.getLength() > 0; } -Error ModuleDebugStream::commit() { return Error::success(); } +Error ModuleDebugStreamRef::commit() { return Error::success(); } diff --git a/tools/llvm-pdbdump/C13DebugFragmentVisitor.cpp b/tools/llvm-pdbdump/C13DebugFragmentVisitor.cpp index b4e64bf634d..940b38c4a8c 100644 --- a/tools/llvm-pdbdump/C13DebugFragmentVisitor.cpp +++ b/tools/llvm-pdbdump/C13DebugFragmentVisitor.cpp @@ -24,19 +24,19 @@ C13DebugFragmentVisitor::C13DebugFragmentVisitor(PDBFile &F) : F(F) {} C13DebugFragmentVisitor::~C13DebugFragmentVisitor() {} Error C13DebugFragmentVisitor::visitUnknown( - codeview::ModuleDebugUnknownFragment &Fragment) { + codeview::ModuleDebugUnknownFragmentRef &Fragment) { return Error::success(); } Error C13DebugFragmentVisitor::visitFileChecksums( - codeview::ModuleDebugFileChecksumFragment &Checksums) { + codeview::ModuleDebugFileChecksumFragmentRef &Checksums) { assert(!this->Checksums.hasValue()); this->Checksums = Checksums; return Error::success(); } Error C13DebugFragmentVisitor::visitLines( - codeview::ModuleDebugLineFragment &Lines) { + codeview::ModuleDebugLineFragmentRef &Lines) { this->Lines.push_back(Lines); return Error::success(); } diff --git a/tools/llvm-pdbdump/C13DebugFragmentVisitor.h b/tools/llvm-pdbdump/C13DebugFragmentVisitor.h index e4a51ce2adc..f0a536c6adc 100644 --- a/tools/llvm-pdbdump/C13DebugFragmentVisitor.h +++ b/tools/llvm-pdbdump/C13DebugFragmentVisitor.h @@ -28,12 +28,12 @@ public: C13DebugFragmentVisitor(PDBFile &F); ~C13DebugFragmentVisitor(); - Error visitUnknown(codeview::ModuleDebugUnknownFragment &Fragment) final; + Error visitUnknown(codeview::ModuleDebugUnknownFragmentRef &Fragment) final; Error visitFileChecksums( - codeview::ModuleDebugFileChecksumFragment &Checksums) final; + codeview::ModuleDebugFileChecksumFragmentRef &Checksums) final; - Error visitLines(codeview::ModuleDebugLineFragment &Lines) final; + Error visitLines(codeview::ModuleDebugLineFragmentRef &Lines) final; Error finished() final; @@ -44,8 +44,8 @@ protected: Expected getNameFromStringTable(uint32_t Offset); Expected getNameFromChecksumsBuffer(uint32_t Offset); - Optional Checksums; - std::vector Lines; + Optional Checksums; + std::vector Lines; PDBFile &F; }; diff --git a/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/tools/llvm-pdbdump/LLVMOutputStyle.cpp index 8ed1a9020c4..eec0793e2dd 100644 --- a/tools/llvm-pdbdump/LLVMOutputStyle.cpp +++ b/tools/llvm-pdbdump/LLVMOutputStyle.cpp @@ -80,8 +80,6 @@ struct PageStats { BitVector UseAfterFreePages; }; -// Define a locally scoped visitor to print the different -// substream types types. class C13RawVisitor : public C13DebugFragmentVisitor { public: C13RawVisitor(ScopedPrinter &P, PDBFile &F) @@ -723,7 +721,7 @@ Error LLVMOutputStyle::dumpDbiStream() { File.getMsfLayout(), File.getMsfBuffer(), Modi.Info.getModuleStreamIndex()); - ModuleDebugStream ModS(Modi.Info, std::move(ModStreamData)); + ModuleDebugStreamRef ModS(Modi.Info, std::move(ModStreamData)); if (auto EC = ModS.reload()) return EC; @@ -751,7 +749,6 @@ Error LLVMOutputStyle::dumpDbiStream() { if (opts::raw::DumpLineInfo) { ListScope SS(P, "LineInfo"); - // Inlinee Line Type Indices refer to the IPI stream. C13RawVisitor V(P, File); if (auto EC = codeview::visitModuleDebugFragments( ModS.linesAndChecksums(), V)) diff --git a/tools/llvm-pdbdump/YAMLOutputStyle.cpp b/tools/llvm-pdbdump/YAMLOutputStyle.cpp index a3fff552547..770d227e553 100644 --- a/tools/llvm-pdbdump/YAMLOutputStyle.cpp +++ b/tools/llvm-pdbdump/YAMLOutputStyle.cpp @@ -157,7 +157,7 @@ private: } Expected> -YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStream &ModS) { +YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS) { if (!ModS.hasLineInfo()) return None; @@ -286,9 +286,10 @@ Error YAMLOutputStyle::dumpDbiStream() { continue; auto ModStreamData = msf::MappedBlockStream::createIndexedStream( - File.getMsfLayout(), File.getMsfBuffer(), ModiStream); + File.getMsfLayout(), File.getMsfBuffer(), + MI.Info.getModuleStreamIndex()); - pdb::ModuleDebugStream ModS(MI.Info, std::move(ModStreamData)); + pdb::ModuleDebugStreamRef ModS(MI.Info, std::move(ModStreamData)); if (auto EC = ModS.reload()) return EC; diff --git a/tools/llvm-pdbdump/YAMLOutputStyle.h b/tools/llvm-pdbdump/YAMLOutputStyle.h index 0918ca46c71..517c7d86d7a 100644 --- a/tools/llvm-pdbdump/YAMLOutputStyle.h +++ b/tools/llvm-pdbdump/YAMLOutputStyle.h @@ -19,7 +19,7 @@ namespace llvm { namespace pdb { -class ModuleDebugStream; +class ModuleDebugStreamRef; class YAMLOutputStyle : public OutputStyle { public: @@ -29,7 +29,7 @@ public: private: Expected> - getFileLineInfo(const pdb::ModuleDebugStream &ModS); + getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS); Error dumpStringTable(); Error dumpFileHeaders(); diff --git a/tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp b/tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp index b6688669c65..14cd222d138 100644 --- a/tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp +++ b/tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp @@ -90,7 +90,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { consumeError(ModStreamData.takeError()); return 0; } - pdb::ModuleDebugStream ModS(Modi.Info, std::move(*ModStreamData)); + pdb::ModuleDebugStreamRef ModS(Modi.Info, std::move(*ModStreamData)); if (auto E = ModS.reload()) { consumeError(std::move(E)); return 0; diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index f744e8dac56..abe0e8d6965 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -897,7 +897,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, BinaryByteStream LineTableInfo(FunctionLineTables[Name], support::little); BinaryStreamReader Reader(LineTableInfo); - ModuleDebugLineFragment LineInfo; + ModuleDebugLineFragmentRef LineInfo; error(LineInfo.initialize(Reader)); W.printHex("Flags", LineInfo.header()->Flags); @@ -964,7 +964,7 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection, void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) { BinaryByteStream S(Subsection, llvm::support::little); BinaryStreamReader SR(S); - ModuleDebugFileChecksumFragment Checksums; + ModuleDebugFileChecksumFragmentRef Checksums; error(Checksums.initialize(SR)); for (auto &FC : Checksums) {