[PDB] Move stream index tracking to GSIStreamBuilder
authorReid Kleckner <rnk@google.com>
Tue, 5 May 2020 03:49:26 +0000 (20:49 -0700)
committerReid Kleckner <rnk@google.com>
Tue, 5 May 2020 03:51:09 +0000 (20:51 -0700)
The GSIHashStreamBuilder doesn't need to know the stream index.
Standardize the naming (Idx -> Index in public APIs).

llvm/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h
llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp

index a497956..c4d3543 100644 (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;
index 88eab57..d35c656 100644 (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;
index d6f7e28..d6a187e 100644 (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) {