Expected<std::unique_ptr<DbiStream>> DbiStreamBuilder::build(PDBFile &File, const msf::WritableStream &Buffer) { if (!VerHeader.hasValue()) return make_error<RawError>(raw_error_code::unspecified, "Missing DBI Stream Version"); if (auto EC = finalize()) return std::move(EC); auto StreamData = MappedBlockStream::createIndexedStream(File.getMsfLayout(), Buffer, StreamDBI); auto Dbi = llvm::make_unique<DbiStream>(File, std::move(StreamData)); Dbi->Header = Header; Dbi->FileInfoSubstream = ReadableStreamRef(FileInfoBuffer); Dbi->ModInfoSubstream = ReadableStreamRef(ModInfoBuffer); if (auto EC = Dbi->initializeModInfoArray()) return std::move(EC); if (auto EC = Dbi->initializeFileInfo()) return std::move(EC); return std::move(Dbi); }
Expected<std::unique_ptr<TpiStream>> TpiStreamBuilder::build(PDBFile &File, const msf::WritableStream &Buffer) { if (!VerHeader.hasValue()) return make_error<RawError>(raw_error_code::unspecified, "Missing TPI Stream Version"); if (auto EC = finalize()) return std::move(EC); auto StreamData = MappedBlockStream::createIndexedStream(File.getMsfLayout(), Buffer, Idx); auto Tpi = llvm::make_unique<TpiStream>(File, std::move(StreamData)); Tpi->Header = Header; Tpi->TypeRecords = VarStreamArray<codeview::CVType>(TypeRecordStream); if (HashValueStream) { Tpi->HashStream = std::move(HashValueStream); StreamReader HSR(*Tpi->HashStream); if (auto EC = HSR.readArray(Tpi->HashValues, TypeRecords.size())) return std::move(EC); } return std::move(Tpi); }