[PDB] Move stream index tracking to GSIStreamBuilder

The GSIHashStreamBuilder doesn't need to know the stream index.
Standardize the naming (Idx -> Index in public APIs).
This commit is contained in:
Reid Kleckner 2020-05-04 20:49:26 -07:00
parent 93f7e525f5
commit b7438c25ea
3 changed files with 12 additions and 18 deletions

View File

@ -51,9 +51,9 @@ public:
Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer);
uint32_t getPublicsStreamIndex() const;
uint32_t getGlobalsStreamIndex() const;
uint32_t getRecordStreamIdx() const { return RecordStreamIdx; }
uint32_t getPublicsStreamIndex() const { return PublicsStreamIndex; }
uint32_t getGlobalsStreamIndex() const { return GlobalsStreamIndex; }
uint32_t getRecordStreamIndex() const { return RecordStreamIndex; }
void addPublicSymbol(const codeview::PublicSym32 &Pub);
@ -69,7 +69,9 @@ private:
Error commitPublicsHashStream(WritableBinaryStreamRef Stream);
Error commitGlobalsHashStream(WritableBinaryStreamRef Stream);
uint32_t RecordStreamIdx = kInvalidStreamIndex;
uint32_t PublicsStreamIndex = kInvalidStreamIndex;
uint32_t GlobalsStreamIndex = kInvalidStreamIndex;
uint32_t RecordStreamIndex = kInvalidStreamIndex;
msf::MSFBuilder &Msf;
std::unique_ptr<GSIHashStreamBuilder> PSH;
std::unique_ptr<GSIHashStreamBuilder> GSH;

View File

@ -49,7 +49,6 @@ struct llvm::pdb::GSIHashStreamBuilder {
};
std::vector<CVSymbol> Records;
uint32_t StreamIndex;
llvm::DenseSet<CVSymbol, SymbolDenseMapInfo> SymbolHashes;
std::vector<PSHashRecord> HashRecords;
std::array<support::ulittle32_t, (IPHR_HASH + 32) / 32> HashBitmap;
@ -213,11 +212,12 @@ Error GSIStreamBuilder::finalizeMsfLayout() {
Expected<uint32_t> Idx = Msf.addStream(calculateGlobalsHashStreamSize());
if (!Idx)
return Idx.takeError();
GSH->StreamIndex = *Idx;
GlobalsStreamIndex = *Idx;
Idx = Msf.addStream(calculatePublicsHashStreamSize());
if (!Idx)
return Idx.takeError();
PSH->StreamIndex = *Idx;
PublicsStreamIndex = *Idx;
uint32_t RecordBytes =
GSH->calculateRecordByteSize() + PSH->calculateRecordByteSize();
@ -225,7 +225,7 @@ Error GSIStreamBuilder::finalizeMsfLayout() {
Idx = Msf.addStream(RecordBytes);
if (!Idx)
return Idx.takeError();
RecordStreamIdx = *Idx;
RecordStreamIndex = *Idx;
return Error::success();
}
@ -286,14 +286,6 @@ static std::vector<ulittle32_t> computeAddrMap(ArrayRef<CVSymbol> Records) {
return AddrMap;
}
uint32_t GSIStreamBuilder::getPublicsStreamIndex() const {
return PSH->StreamIndex;
}
uint32_t GSIStreamBuilder::getGlobalsStreamIndex() const {
return GSH->StreamIndex;
}
void GSIStreamBuilder::addPublicSymbol(const PublicSym32 &Pub) {
PSH->addSymbol(Pub, Msf);
}
@ -377,7 +369,7 @@ Error GSIStreamBuilder::commit(const msf::MSFLayout &Layout,
auto PS = WritableMappedBlockStream::createIndexedStream(
Layout, Buffer, getPublicsStreamIndex(), Msf.getAllocator());
auto PRS = WritableMappedBlockStream::createIndexedStream(
Layout, Buffer, getRecordStreamIdx(), Msf.getAllocator());
Layout, Buffer, getRecordStreamIndex(), Msf.getAllocator());
if (auto EC = commitSymbolRecordStream(*PRS))
return EC;

View File

@ -144,7 +144,7 @@ Error PDBFileBuilder::finalizeMsfLayout() {
if (Dbi) {
Dbi->setPublicsStreamIndex(Gsi->getPublicsStreamIndex());
Dbi->setGlobalsStreamIndex(Gsi->getGlobalsStreamIndex());
Dbi->setSymbolRecordStreamIndex(Gsi->getRecordStreamIdx());
Dbi->setSymbolRecordStreamIndex(Gsi->getRecordStreamIndex());
}
}
if (Tpi) {