]> granicus.if.org Git - llvm/commitdiff
Remove PDBFileBuilder::build() and related functions.
authorRui Ueyama <ruiu@google.com>
Tue, 22 Nov 2016 20:32:22 +0000 (20:32 +0000)
committerRui Ueyama <ruiu@google.com>
Tue, 22 Nov 2016 20:32:22 +0000 (20:32 +0000)
PDBFileBuilder supports two different ways to create files.
One is PDBFileBuilder::commit. That function takes a filename
and write a result to the file. The other is PDBFileBuilder::build.
That returns a new PDBFile object.

This patch removes the latter because no one is using it and
in a real life situation we are very unlikely to need it.
Even if you need it, it'd be easy to write a new PDB to a memory
buffer and read it back.

Removing PDBFileBuilder::build enables us to remove other classes
build transitively.

Differential Revision: https://reviews.llvm.org/D26987

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287697 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h
include/llvm/DebugInfo/PDB/Raw/InfoStreamBuilder.h
include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
include/llvm/DebugInfo/PDB/Raw/TpiStreamBuilder.h
lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp
lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp
lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
lib/DebugInfo/PDB/Raw/TpiStreamBuilder.cpp

index da1eab8adef1374733e6bc37ec13dd1399f4df4a..99a3ac7fb1da22ca7ab93198ad4fff4fd0a8b97c 100644 (file)
@@ -60,7 +60,6 @@ public:
 
   Error finalizeMsfLayout();
 
-  Expected<std::unique_ptr<DbiStream>> build(PDBFile &File);
   Error commit(const msf::MSFLayout &Layout,
                const msf::WritableStream &Buffer);
 
index 5afbf820a0cea775ba9b93fa4b531e8d6797b2b1..cb60b1eb69bd655893be8e0e5379ddd51d3cc448 100644 (file)
@@ -43,8 +43,6 @@ public:
 
   Error finalizeMsfLayout();
 
-  Expected<std::unique_ptr<InfoStream>> build(PDBFile &File);
-
   Error commit(const msf::MSFLayout &Layout,
                const msf::WritableStream &Buffer) const;
 
index 3045ab70a2d97501c9c78211dfc1504ff9c3d8b2..27fc4b53b64928f249b86d3d731a3258f647893b 100644 (file)
@@ -45,9 +45,6 @@ public:
   TpiStreamBuilder &getTpiBuilder();
   TpiStreamBuilder &getIpiBuilder();
 
-  Expected<std::unique_ptr<PDBFile>>
-  build(std::unique_ptr<msf::WritableStream> PdbFileBuffer);
-
   Error commit(StringRef Filename);
 
 private:
index 937b188e96ea2b2e2021943b00cce2b06ca485da..f9a642126f531837ecb8fb98dc285dea01e7a134 100644 (file)
@@ -56,8 +56,6 @@ public:
 
   Error finalizeMsfLayout();
 
-  Expected<std::unique_ptr<TpiStream>> build(PDBFile &File);
-
   Error commit(const msf::MSFLayout &Layout, const msf::WritableStream &Buffer);
 
   uint32_t calculateSerializedLength() const;
index 33c07ffa3b8decac17d893434e8739e47968bd6a..1d5b8d693b1eaea6612bca9a84e88da761fc4bd7 100644 (file)
@@ -357,27 +357,6 @@ std::vector<SecMapEntry> DbiStreamBuilder::createSectionMap(
   return Ret;
 }
 
-Expected<std::unique_ptr<DbiStream>>
-DbiStreamBuilder::build(PDBFile &File) {
-  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(), File.getMsfBuffer(), 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);
-}
-
 Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
                                const msf::WritableStream &Buffer) {
   if (auto EC = finalize())
index e909c30e95f0729bbaca32c95624f01648e53631..73fbf853b4f702f114501fe625361da357719472 100644 (file)
@@ -47,22 +47,6 @@ Error InfoStreamBuilder::finalizeMsfLayout() {
   return Error::success();
 }
 
-Expected<std::unique_ptr<InfoStream>>
-InfoStreamBuilder::build(PDBFile &File) {
-  auto StreamData = MappedBlockStream::createIndexedStream(
-      File.getMsfLayout(), File.getMsfBuffer(), StreamPDB);
-  auto Info = llvm::make_unique<InfoStream>(std::move(StreamData));
-  Info->Version = Ver;
-  Info->Signature = Sig;
-  Info->Age = Age;
-  Info->Guid = Guid;
-  auto NS = NamedStreams.build();
-  if (!NS)
-    return NS.takeError();
-  Info->NamedStreams = **NS;
-  return std::move(Info);
-}
-
 Error InfoStreamBuilder::commit(const msf::MSFLayout &Layout,
                                 const msf::WritableStream &Buffer) const {
   auto InfoS =
index e47d11cf61a3b101d0419b33f21e2b3446c364ef..6fec0e32a8ae7f4641c7b6377027ed1584ea1d2a 100644 (file)
@@ -87,51 +87,6 @@ Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() const {
   return Msf->build();
 }
 
-Expected<std::unique_ptr<PDBFile>>
-PDBFileBuilder::build(std::unique_ptr<msf::WritableStream> PdbFileBuffer) {
-  auto ExpectedLayout = finalizeMsfLayout();
-  if (!ExpectedLayout)
-    return ExpectedLayout.takeError();
-
-  auto File = llvm::make_unique<PDBFile>(std::move(PdbFileBuffer), Allocator);
-  File->ContainerLayout = *ExpectedLayout;
-
-  if (Info) {
-    auto ExpectedInfo = Info->build(*File);
-    if (!ExpectedInfo)
-      return ExpectedInfo.takeError();
-    File->Info = std::move(*ExpectedInfo);
-  }
-
-  if (Dbi) {
-    auto ExpectedDbi = Dbi->build(*File);
-    if (!ExpectedDbi)
-      return ExpectedDbi.takeError();
-    File->Dbi = std::move(*ExpectedDbi);
-  }
-
-  if (Tpi) {
-    auto ExpectedTpi = Tpi->build(*File);
-    if (!ExpectedTpi)
-      return ExpectedTpi.takeError();
-    File->Tpi = std::move(*ExpectedTpi);
-  }
-
-  if (Ipi) {
-    auto ExpectedIpi = Ipi->build(*File);
-    if (!ExpectedIpi)
-      return ExpectedIpi.takeError();
-    File->Ipi = std::move(*ExpectedIpi);
-  }
-
-  if (File->Info && File->Dbi && File->Info->getAge() != File->Dbi->getAge())
-    return llvm::make_error<RawError>(
-        raw_error_code::corrupt_file,
-        "PDB Stream Age doesn't match Dbi Stream Age!");
-
-  return std::move(File);
-}
-
 Error PDBFileBuilder::commit(StringRef Filename) {
   auto ExpectedLayout = finalizeMsfLayout();
   if (!ExpectedLayout)
index d8bae59195ce5aeaf6f20e4c632dd746caf46379..aa3547c93c4bdacf9474b7a4584f0bfd582d84a1 100644 (file)
@@ -99,27 +99,6 @@ Error TpiStreamBuilder::finalizeMsfLayout() {
   return Error::success();
 }
 
-Expected<std::unique_ptr<TpiStream>> TpiStreamBuilder::build(PDBFile &File) {
-  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(), File.getMsfBuffer(), 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);
-}
-
 Error TpiStreamBuilder::commit(const msf::MSFLayout &Layout,
                                const msf::WritableStream &Buffer) {
   if (auto EC = finalize())