[PDB/CodeView] Rename some classes.

In preparation for introducing writing capabilities for each of
these classes, I would like to adopt a Foo / FooRef naming
convention, where Foo indicates that the class can manipulate and
serialize Foos, and FooRef indicates that it is an immutable view of
an existing Foo.  In other words, Foo is a writer and FooRef is a
reader.  This patch names some existing readers to conform to the
FooRef convention, while offering no functional change.

llvm-svn: 301810
This commit is contained in:
Zachary Turner 2017-05-01 16:46:39 +00:00
parent 8a6238201f
commit 7cc13e557c
18 changed files with 69 additions and 67 deletions

View File

@ -1,4 +1,4 @@
//===- ModuleDebugLineFragment.h --------------------------------*- C++ -*-===// //===- ModuleDebugFileChecksumFragment.h ------------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -39,15 +39,15 @@ public:
namespace llvm { namespace llvm {
namespace codeview { namespace codeview {
class ModuleDebugFileChecksumFragment final : public ModuleDebugFragment { class ModuleDebugFileChecksumFragmentRef final : public ModuleDebugFragmentRef {
typedef VarStreamArray<FileChecksumEntry> FileChecksumArray; typedef VarStreamArray<codeview::FileChecksumEntry> FileChecksumArray;
typedef FileChecksumArray::Iterator Iterator; typedef FileChecksumArray::Iterator Iterator;
public: public:
ModuleDebugFileChecksumFragment() ModuleDebugFileChecksumFragmentRef()
: ModuleDebugFragment(ModuleDebugFragmentKind::FileChecksums) {} : ModuleDebugFragmentRef(ModuleDebugFragmentKind::FileChecksums) {}
static bool classof(const ModuleDebugFragment *S) { static bool classof(const ModuleDebugFragmentRef *S) {
return S->kind() == ModuleDebugFragmentKind::FileChecksums; return S->kind() == ModuleDebugFragmentKind::FileChecksums;
} }

View File

@ -16,11 +16,11 @@
namespace llvm { namespace llvm {
namespace codeview { namespace codeview {
class ModuleDebugFragment { class ModuleDebugFragmentRef {
public: public:
explicit ModuleDebugFragment(ModuleDebugFragmentKind Kind) : Kind(Kind) {} explicit ModuleDebugFragmentRef(ModuleDebugFragmentKind Kind) : Kind(Kind) {}
virtual ~ModuleDebugFragmentRef();
virtual ~ModuleDebugFragment();
ModuleDebugFragmentKind kind() const { return Kind; } ModuleDebugFragmentKind kind() const { return Kind; }
protected: protected:

View File

@ -17,24 +17,25 @@ namespace llvm {
namespace codeview { namespace codeview {
class ModuleDebugFileChecksumFragment; class ModuleDebugFileChecksumFragmentRef;
class ModuleDebugFragmentRecord; class ModuleDebugFragmentRecord;
class ModuleDebugInlineeLineFragment; class ModuleDebugInlineeLineFragmentRef;
class ModuleDebugLineFragment; class ModuleDebugLineFragmentRef;
class ModuleDebugUnknownFragment; class ModuleDebugUnknownFragmentRef;
class ModuleDebugFragmentVisitor { class ModuleDebugFragmentVisitor {
public: public:
virtual ~ModuleDebugFragmentVisitor() = default; virtual ~ModuleDebugFragmentVisitor() = default;
virtual Error visitUnknown(ModuleDebugUnknownFragment &Unknown) { virtual Error visitUnknown(ModuleDebugUnknownFragmentRef &Unknown) {
return Error::success(); return Error::success();
} }
virtual Error visitLines(ModuleDebugLineFragment &Lines) { virtual Error visitLines(ModuleDebugLineFragmentRef &Lines) {
return Error::success(); return Error::success();
} }
virtual Error visitFileChecksums(ModuleDebugFileChecksumFragment &Checksums) { virtual Error
visitFileChecksums(ModuleDebugFileChecksumFragmentRef &Checksums) {
return Error::success(); return Error::success();
} }

View File

@ -63,15 +63,15 @@ public:
LineColumnEntry &Item, const LineFragmentHeader *Header); LineColumnEntry &Item, const LineFragmentHeader *Header);
}; };
class ModuleDebugLineFragment final : public ModuleDebugFragment { class ModuleDebugLineFragmentRef final : public ModuleDebugFragmentRef {
friend class LineColumnExtractor; friend class LineColumnExtractor;
typedef VarStreamArray<LineColumnEntry, LineColumnExtractor> LineInfoArray; typedef VarStreamArray<LineColumnEntry, LineColumnExtractor> LineInfoArray;
typedef LineInfoArray::Iterator Iterator; typedef LineInfoArray::Iterator Iterator;
public: public:
ModuleDebugLineFragment(); ModuleDebugLineFragmentRef();
static bool classof(const ModuleDebugFragment *S) { static bool classof(const ModuleDebugFragmentRef *S) {
return S->kind() == ModuleDebugFragmentKind::Lines; return S->kind() == ModuleDebugFragmentKind::Lines;
} }

View File

@ -16,10 +16,11 @@
namespace llvm { namespace llvm {
namespace codeview { namespace codeview {
class ModuleDebugUnknownFragment final : public ModuleDebugFragment { class ModuleDebugUnknownFragmentRef final : public ModuleDebugFragmentRef {
public: public:
ModuleDebugUnknownFragment(ModuleDebugFragmentKind Kind, BinaryStreamRef Data) ModuleDebugUnknownFragmentRef(ModuleDebugFragmentKind Kind,
: ModuleDebugFragment(Kind), Data(Data) {} BinaryStreamRef Data)
: ModuleDebugFragmentRef(Kind), Data(Data) {}
BinaryStreamRef getData() const { return Data; } BinaryStreamRef getData() const { return Data; }

View File

@ -24,14 +24,14 @@ namespace pdb {
class PDBFile; class PDBFile;
class DbiModuleDescriptor; class DbiModuleDescriptor;
class ModuleDebugStream { class ModuleDebugStreamRef {
typedef codeview::ModuleDebugFragmentArray::Iterator typedef codeview::ModuleDebugFragmentArray::Iterator
LinesAndChecksumsIterator; LinesAndChecksumsIterator;
public: public:
ModuleDebugStream(const DbiModuleDescriptor &Module, ModuleDebugStreamRef(const DbiModuleDescriptor &Module,
std::unique_ptr<msf::MappedBlockStream> Stream); std::unique_ptr<msf::MappedBlockStream> Stream);
~ModuleDebugStream(); ~ModuleDebugStreamRef();
Error reload(); Error reload();
@ -54,7 +54,7 @@ private:
std::unique_ptr<msf::MappedBlockStream> Stream; std::unique_ptr<msf::MappedBlockStream> Stream;
codeview::CVSymbolArray SymbolsSubstream; codeview::CVSymbolArray SymbolsSubstream;
BinaryStreamRef LinesSubstream; BinaryStreamRef C11LinesSubstream;
BinaryStreamRef C13LinesSubstream; BinaryStreamRef C13LinesSubstream;
BinaryStreamRef GlobalRefsSubstream; BinaryStreamRef GlobalRefsSubstream;

View File

@ -41,7 +41,8 @@ Error llvm::VarStreamArrayExtractor<FileChecksumEntry>::extract(
return Error::success(); return Error::success();
} }
Error ModuleDebugFileChecksumFragment::initialize(BinaryStreamReader Reader) { Error ModuleDebugFileChecksumFragmentRef::initialize(
BinaryStreamReader Reader) {
if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining())) if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining()))
return EC; return EC;

View File

@ -11,4 +11,4 @@
using namespace llvm::codeview; using namespace llvm::codeview;
ModuleDebugFragment::~ModuleDebugFragment() {} ModuleDebugFragmentRef::~ModuleDebugFragmentRef() {}

View File

@ -24,21 +24,21 @@ Error llvm::codeview::visitModuleDebugFragment(
BinaryStreamReader Reader(R.getRecordData()); BinaryStreamReader Reader(R.getRecordData());
switch (R.kind()) { switch (R.kind()) {
case ModuleDebugFragmentKind::Lines: { case ModuleDebugFragmentKind::Lines: {
ModuleDebugLineFragment Fragment; ModuleDebugLineFragmentRef Fragment;
if (auto EC = Fragment.initialize(Reader)) if (auto EC = Fragment.initialize(Reader))
return EC; return EC;
return V.visitLines(Fragment); return V.visitLines(Fragment);
} }
case ModuleDebugFragmentKind::FileChecksums: { case ModuleDebugFragmentKind::FileChecksums: {
ModuleDebugFileChecksumFragment Fragment; ModuleDebugFileChecksumFragmentRef Fragment;
if (auto EC = Fragment.initialize(Reader)) if (auto EC = Fragment.initialize(Reader))
return EC; return EC;
return V.visitFileChecksums(Fragment); return V.visitFileChecksums(Fragment);
} }
default: { default: {
ModuleDebugUnknownFragment Fragment(R.kind(), R.getRecordData()); ModuleDebugUnknownFragmentRef Fragment(R.kind(), R.getRecordData());
return V.visitUnknown(Fragment); return V.visitUnknown(Fragment);
} }
} }

View File

@ -47,10 +47,10 @@ Error LineColumnExtractor::extract(BinaryStreamRef Stream, uint32_t &Len,
return Error::success(); return Error::success();
} }
ModuleDebugLineFragment::ModuleDebugLineFragment() ModuleDebugLineFragmentRef::ModuleDebugLineFragmentRef()
: ModuleDebugFragment(ModuleDebugFragmentKind::Lines) {} : ModuleDebugFragmentRef(ModuleDebugFragmentKind::Lines) {}
Error ModuleDebugLineFragment::initialize(BinaryStreamReader Reader) { Error ModuleDebugLineFragmentRef::initialize(BinaryStreamReader Reader) {
if (auto EC = Reader.readObject(Header)) if (auto EC = Reader.readObject(Header))
return EC; return EC;
@ -61,6 +61,6 @@ Error ModuleDebugLineFragment::initialize(BinaryStreamReader Reader) {
return Error::success(); return Error::success();
} }
bool ModuleDebugLineFragment::hasColumnInfo() const { bool ModuleDebugLineFragmentRef::hasColumnInfo() const {
return Header->Flags & LF_HaveColumns; return !!(Header->Flags & LF_HaveColumns);
} }

View File

@ -25,13 +25,14 @@ using namespace llvm::codeview;
using namespace llvm::msf; using namespace llvm::msf;
using namespace llvm::pdb; using namespace llvm::pdb;
ModuleDebugStream::ModuleDebugStream(const DbiModuleDescriptor &Module, ModuleDebugStreamRef::ModuleDebugStreamRef(
std::unique_ptr<MappedBlockStream> Stream) const DbiModuleDescriptor &Module,
std::unique_ptr<MappedBlockStream> Stream)
: Mod(Module), Stream(std::move(Stream)) {} : Mod(Module), Stream(std::move(Stream)) {}
ModuleDebugStream::~ModuleDebugStream() = default; ModuleDebugStreamRef::~ModuleDebugStreamRef() = default;
Error ModuleDebugStream::reload() { Error ModuleDebugStreamRef::reload() {
BinaryStreamReader Reader(*Stream); BinaryStreamReader Reader(*Stream);
uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize(); uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
@ -49,7 +50,7 @@ Error ModuleDebugStream::reload() {
if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4)) if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4))
return EC; return EC;
if (auto EC = Reader.readStreamRef(LinesSubstream, C11Size)) if (auto EC = Reader.readStreamRef(C11LinesSubstream, C11Size))
return EC; return EC;
if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size)) if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size))
return EC; return EC;
@ -72,17 +73,17 @@ Error ModuleDebugStream::reload() {
} }
iterator_range<codeview::CVSymbolArray::Iterator> iterator_range<codeview::CVSymbolArray::Iterator>
ModuleDebugStream::symbols(bool *HadError) const { ModuleDebugStreamRef::symbols(bool *HadError) const {
return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end()); return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end());
} }
llvm::iterator_range<ModuleDebugStream::LinesAndChecksumsIterator> llvm::iterator_range<ModuleDebugStreamRef::LinesAndChecksumsIterator>
ModuleDebugStream::linesAndChecksums() const { ModuleDebugStreamRef::linesAndChecksums() const {
return make_range(LinesAndChecksums.begin(), LinesAndChecksums.end()); return make_range(LinesAndChecksums.begin(), LinesAndChecksums.end());
} }
bool ModuleDebugStream::hasLineInfo() const { bool ModuleDebugStreamRef::hasLineInfo() const {
return C13LinesSubstream.getLength() > 0; return C13LinesSubstream.getLength() > 0;
} }
Error ModuleDebugStream::commit() { return Error::success(); } Error ModuleDebugStreamRef::commit() { return Error::success(); }

View File

@ -24,19 +24,19 @@ C13DebugFragmentVisitor::C13DebugFragmentVisitor(PDBFile &F) : F(F) {}
C13DebugFragmentVisitor::~C13DebugFragmentVisitor() {} C13DebugFragmentVisitor::~C13DebugFragmentVisitor() {}
Error C13DebugFragmentVisitor::visitUnknown( Error C13DebugFragmentVisitor::visitUnknown(
codeview::ModuleDebugUnknownFragment &Fragment) { codeview::ModuleDebugUnknownFragmentRef &Fragment) {
return Error::success(); return Error::success();
} }
Error C13DebugFragmentVisitor::visitFileChecksums( Error C13DebugFragmentVisitor::visitFileChecksums(
codeview::ModuleDebugFileChecksumFragment &Checksums) { codeview::ModuleDebugFileChecksumFragmentRef &Checksums) {
assert(!this->Checksums.hasValue()); assert(!this->Checksums.hasValue());
this->Checksums = Checksums; this->Checksums = Checksums;
return Error::success(); return Error::success();
} }
Error C13DebugFragmentVisitor::visitLines( Error C13DebugFragmentVisitor::visitLines(
codeview::ModuleDebugLineFragment &Lines) { codeview::ModuleDebugLineFragmentRef &Lines) {
this->Lines.push_back(Lines); this->Lines.push_back(Lines);
return Error::success(); return Error::success();
} }

View File

@ -28,12 +28,12 @@ public:
C13DebugFragmentVisitor(PDBFile &F); C13DebugFragmentVisitor(PDBFile &F);
~C13DebugFragmentVisitor(); ~C13DebugFragmentVisitor();
Error visitUnknown(codeview::ModuleDebugUnknownFragment &Fragment) final; Error visitUnknown(codeview::ModuleDebugUnknownFragmentRef &Fragment) final;
Error visitFileChecksums( 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; Error finished() final;
@ -44,8 +44,8 @@ protected:
Expected<StringRef> getNameFromStringTable(uint32_t Offset); Expected<StringRef> getNameFromStringTable(uint32_t Offset);
Expected<StringRef> getNameFromChecksumsBuffer(uint32_t Offset); Expected<StringRef> getNameFromChecksumsBuffer(uint32_t Offset);
Optional<codeview::ModuleDebugFileChecksumFragment> Checksums; Optional<codeview::ModuleDebugFileChecksumFragmentRef> Checksums;
std::vector<codeview::ModuleDebugLineFragment> Lines; std::vector<codeview::ModuleDebugLineFragmentRef> Lines;
PDBFile &F; PDBFile &F;
}; };

View File

@ -80,8 +80,6 @@ struct PageStats {
BitVector UseAfterFreePages; BitVector UseAfterFreePages;
}; };
// Define a locally scoped visitor to print the different
// substream types types.
class C13RawVisitor : public C13DebugFragmentVisitor { class C13RawVisitor : public C13DebugFragmentVisitor {
public: public:
C13RawVisitor(ScopedPrinter &P, PDBFile &F) C13RawVisitor(ScopedPrinter &P, PDBFile &F)
@ -723,7 +721,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
File.getMsfLayout(), File.getMsfBuffer(), File.getMsfLayout(), File.getMsfBuffer(),
Modi.Info.getModuleStreamIndex()); Modi.Info.getModuleStreamIndex());
ModuleDebugStream ModS(Modi.Info, std::move(ModStreamData)); ModuleDebugStreamRef ModS(Modi.Info, std::move(ModStreamData));
if (auto EC = ModS.reload()) if (auto EC = ModS.reload())
return EC; return EC;
@ -751,7 +749,6 @@ Error LLVMOutputStyle::dumpDbiStream() {
if (opts::raw::DumpLineInfo) { if (opts::raw::DumpLineInfo) {
ListScope SS(P, "LineInfo"); ListScope SS(P, "LineInfo");
// Inlinee Line Type Indices refer to the IPI stream.
C13RawVisitor V(P, File); C13RawVisitor V(P, File);
if (auto EC = codeview::visitModuleDebugFragments( if (auto EC = codeview::visitModuleDebugFragments(
ModS.linesAndChecksums(), V)) ModS.linesAndChecksums(), V))

View File

@ -157,7 +157,7 @@ private:
} }
Expected<Optional<llvm::pdb::yaml::PdbSourceFileInfo>> Expected<Optional<llvm::pdb::yaml::PdbSourceFileInfo>>
YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStream &ModS) { YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS) {
if (!ModS.hasLineInfo()) if (!ModS.hasLineInfo())
return None; return None;
@ -286,9 +286,10 @@ Error YAMLOutputStyle::dumpDbiStream() {
continue; continue;
auto ModStreamData = msf::MappedBlockStream::createIndexedStream( 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()) if (auto EC = ModS.reload())
return EC; return EC;

View File

@ -19,7 +19,7 @@
namespace llvm { namespace llvm {
namespace pdb { namespace pdb {
class ModuleDebugStream; class ModuleDebugStreamRef;
class YAMLOutputStyle : public OutputStyle { class YAMLOutputStyle : public OutputStyle {
public: public:
@ -29,7 +29,7 @@ public:
private: private:
Expected<Optional<llvm::pdb::yaml::PdbSourceFileInfo>> Expected<Optional<llvm::pdb::yaml::PdbSourceFileInfo>>
getFileLineInfo(const pdb::ModuleDebugStream &ModS); getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS);
Error dumpStringTable(); Error dumpStringTable();
Error dumpFileHeaders(); Error dumpFileHeaders();

View File

@ -90,7 +90,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
consumeError(ModStreamData.takeError()); consumeError(ModStreamData.takeError());
return 0; return 0;
} }
pdb::ModuleDebugStream ModS(Modi.Info, std::move(*ModStreamData)); pdb::ModuleDebugStreamRef ModS(Modi.Info, std::move(*ModStreamData));
if (auto E = ModS.reload()) { if (auto E = ModS.reload()) {
consumeError(std::move(E)); consumeError(std::move(E));
return 0; return 0;

View File

@ -897,7 +897,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
BinaryByteStream LineTableInfo(FunctionLineTables[Name], support::little); BinaryByteStream LineTableInfo(FunctionLineTables[Name], support::little);
BinaryStreamReader Reader(LineTableInfo); BinaryStreamReader Reader(LineTableInfo);
ModuleDebugLineFragment LineInfo; ModuleDebugLineFragmentRef LineInfo;
error(LineInfo.initialize(Reader)); error(LineInfo.initialize(Reader));
W.printHex("Flags", LineInfo.header()->Flags); W.printHex("Flags", LineInfo.header()->Flags);
@ -964,7 +964,7 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) { void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
BinaryByteStream S(Subsection, llvm::support::little); BinaryByteStream S(Subsection, llvm::support::little);
BinaryStreamReader SR(S); BinaryStreamReader SR(S);
ModuleDebugFileChecksumFragment Checksums; ModuleDebugFileChecksumFragmentRef Checksums;
error(Checksums.initialize(SR)); error(Checksums.initialize(SR));
for (auto &FC : Checksums) { for (auto &FC : Checksums) {