@@ -40,7 +40,8 @@ class WritableBinaryStream;
4040}
4141
4242PDBFileBuilder::PDBFileBuilder (BumpPtrAllocator &Allocator)
43- : Allocator(Allocator), InjectedSourceTable(2 ) {}
43+ : Allocator(Allocator), InjectedSourceHashTraits(Strings),
44+ InjectedSourceTable(2 ) {}
4445
4546PDBFileBuilder::~PDBFileBuilder () = default ;
4647
@@ -79,11 +80,7 @@ TpiStreamBuilder &PDBFileBuilder::getIpiBuilder() {
7980}
8081
8182PDBStringTableBuilder &PDBFileBuilder::getStringTableBuilder () {
82- if (!Strings) {
83- Strings = std::make_unique<PDBStringTableBuilder>();
84- InjectedSourceHashTraits = StringTableHashTraits (*Strings);
85- }
86- return *Strings;
83+ return Strings;
8784}
8885
8986GSIStreamBuilder &PDBFileBuilder::getGsiBuilder () {
@@ -92,12 +89,6 @@ GSIStreamBuilder &PDBFileBuilder::getGsiBuilder() {
9289 return *Gsi;
9390}
9491
95- std::unique_ptr<SmallVector<char >> &PDBFileBuilder::getDXContainerData () {
96- if (!Dxc)
97- Dxc = std::make_unique<SmallVector<char >>();
98- return Dxc;
99- }
100-
10192Expected<uint32_t > PDBFileBuilder::allocateNamedStream (StringRef Name,
10293 uint32_t Size) {
10394 auto ExpectedStream = Msf->addStream (Size);
@@ -149,14 +140,11 @@ Error PDBFileBuilder::finalizeMsfLayout() {
149140 Info.addFeature (PdbRaw_FeatureSig::VC140);
150141 }
151142
152- if (Dxc) {
153- if (auto EC = Msf->setStreamSize (StreamDXContainer, Dxc->size ()))
154- return EC;
155- } else {
156- Expected<uint32_t > SN = allocateNamedStream (" /LinkInfo" , 0 );
157- if (!SN)
158- return SN.takeError ();
159- }
143+ uint32_t StringsLen = Strings.calculateSerializedSize ();
144+
145+ Expected<uint32_t > SN = allocateNamedStream (" /LinkInfo" , 0 );
146+ if (!SN)
147+ return SN.takeError ();
160148
161149 if (Gsi) {
162150 if (auto EC = Gsi->finalizeMsfLayout ())
@@ -175,12 +163,10 @@ Error PDBFileBuilder::finalizeMsfLayout() {
175163 if (auto EC = Dbi->finalizeMsfLayout ())
176164 return EC;
177165 }
178- if (Strings) {
179- uint32_t StringsLen = Strings->calculateSerializedSize ();
180- Expected<uint32_t > SN = allocateNamedStream (" /names" , StringsLen);
181- if (!SN)
182- return SN.takeError ();
183- }
166+ SN = allocateNamedStream (" /names" , StringsLen);
167+ if (!SN)
168+ return SN.takeError ();
169+
184170 if (Ipi) {
185171 if (auto EC = Ipi->finalizeMsfLayout ())
186172 return EC;
@@ -217,8 +203,7 @@ Error PDBFileBuilder::finalizeMsfLayout() {
217203 uint32_t SrcHeaderBlockSize =
218204 sizeof (SrcHeaderBlockHeader) +
219205 InjectedSourceTable.calculateSerializedLength ();
220- Expected<uint32_t > SN =
221- allocateNamedStream (" /src/headerblock" , SrcHeaderBlockSize);
206+ SN = allocateNamedStream (" /src/headerblock" , SrcHeaderBlockSize);
222207 if (!SN)
223208 return SN.takeError ();
224209 for (const auto &IS : InjectedSources) {
@@ -297,17 +282,16 @@ Error PDBFileBuilder::commit(StringRef Filename, codeview::GUID *Guid) {
297282 return ExpectedMsfBuffer.takeError ();
298283 FileBufferByteStream Buffer = std::move (*ExpectedMsfBuffer);
299284
300- if (Strings) {
301- auto ExpectedSN = getNamedStreamIndex (" /names" );
302- if (!ExpectedSN)
303- return ExpectedSN.takeError ();
285+ auto ExpectedSN = getNamedStreamIndex (" /names" );
286+ if (!ExpectedSN)
287+ return ExpectedSN.takeError ();
288+
289+ auto NS = WritableMappedBlockStream::createIndexedStream (
290+ Layout, Buffer, *ExpectedSN, Allocator);
291+ BinaryStreamWriter NSWriter (*NS);
292+ if (auto EC = Strings.commit (NSWriter))
293+ return EC;
304294
305- auto NS = WritableMappedBlockStream::createIndexedStream (
306- Layout, Buffer, *ExpectedSN, Allocator);
307- BinaryStreamWriter NSWriter (*NS);
308- if (auto EC = Strings->commit (NSWriter))
309- return EC;
310- }
311295 {
312296 llvm::TimeTraceScope timeScope (" Named stream data" );
313297 for (const auto &NSE : NamedStreamData) {
@@ -347,17 +331,6 @@ Error PDBFileBuilder::commit(StringRef Filename, codeview::GUID *Guid) {
347331 return EC;
348332 }
349333
350- if (Dxc) {
351- llvm::TimeTraceScope timeScope (" DXContainer stream" );
352- auto DxcS = WritableMappedBlockStream::createIndexedStream (
353- Layout, Buffer, StreamDXContainer, Allocator);
354- BinaryStreamWriter Writer (*DxcS);
355- llvm::ArrayRef<uint8_t > DataRef (reinterpret_cast <uint8_t *>(Dxc->data ()),
356- Dxc->size ());
357- if (auto EC = Writer.writeBytes (DataRef))
358- return EC;
359- }
360-
361334 auto InfoStreamBlocks = Layout.StreamMap [StreamPDB];
362335 assert (!InfoStreamBlocks.empty ());
363336 uint64_t InfoStreamFileOffset =
0 commit comments