aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-03 15:58:37 +0000
committerZachary Turner <zturner@google.com>2017-05-03 15:58:37 +0000
commitc504ae3cefc0fab043bb76f992045c9770ef87c1 (patch)
tree1dd725e862fac7c621642cac792d96cf6f5636f3 /llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
parent99b925bdf38840a43ed0f57c37fec389f0388148 (diff)
downloadllvm-c504ae3cefc0fab043bb76f992045c9770ef87c1.zip
llvm-c504ae3cefc0fab043bb76f992045c9770ef87c1.tar.gz
llvm-c504ae3cefc0fab043bb76f992045c9770ef87c1.tar.bz2
Resubmit r301986 and r301987 "Add codeview::StringTable"
This was reverted due to a "missing" file, but in reality what happened was that I renamed a file, and then due to a merge conflict both the old file and the new file got added to the repository. This led to an unused cpp file being in the repo and not referenced by any CMakeLists.txt but #including a .h file that wasn't in the repo. In an even more unfortunate coincidence, CMake didn't report the unused cpp file because it was in a subdirectory of the folder with the CMakeLists.txt, and not in the same directory as any CMakeLists.txt. The presence of the unused file was then breaking certain tools that determine file lists by globbing rather than by what's specified in CMakeLists.txt In any case, the fix is to just remove the unused file from the patch set. llvm-svn: 302042
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
index 972c995..4dd965c 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
@@ -80,9 +80,9 @@ Error PDBFileBuilder::addNamedStream(StringRef Name, uint32_t Size) {
}
Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() {
- uint32_t PDBStringTableSize = Strings.finalize();
+ uint32_t StringsLen = Strings.calculateSerializedSize();
- if (auto EC = addNamedStream("/names", PDBStringTableSize))
+ if (auto EC = addNamedStream("/names", StringsLen))
return std::move(EC);
if (auto EC = addNamedStream("/LinkInfo", 0))
return std::move(EC);
@@ -109,6 +109,13 @@ Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() {
return Msf->build();
}
+Expected<uint32_t> PDBFileBuilder::getNamedStreamIndex(StringRef Name) const {
+ uint32_t SN = 0;
+ if (!NamedStreams.get(Name, SN))
+ return llvm::make_error<pdb::RawError>(raw_error_code::no_stream);
+ return SN;
+}
+
Error PDBFileBuilder::commit(StringRef Filename) {
auto ExpectedLayout = finalizeMsfLayout();
if (!ExpectedLayout)
@@ -146,12 +153,12 @@ Error PDBFileBuilder::commit(StringRef Filename) {
return EC;
}
- uint32_t PDBStringTableStreamNo = 0;
- if (!NamedStreams.get("/names", PDBStringTableStreamNo))
- return llvm::make_error<pdb::RawError>(raw_error_code::no_stream);
+ auto ExpectedSN = getNamedStreamIndex("/names");
+ if (!ExpectedSN)
+ return ExpectedSN.takeError();
- auto NS = WritableMappedBlockStream::createIndexedStream(
- Layout, Buffer, PDBStringTableStreamNo);
+ auto NS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer,
+ *ExpectedSN);
BinaryStreamWriter NSWriter(*NS);
if (auto EC = Strings.commit(NSWriter))
return EC;