Resubmit "[pdb] Allow zero-copy read support for symbol streams.""
Due to differences in template instantiation rules, it is not
portable to static_assert(false) inside of an invalid specialization
of a template. Instead I just =delete the method so that it can't
be used, and leave a comment that it must be explicitly specialized.
llvm-svn: 271027
diff --git a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
index 3593757..1827ab0 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
@@ -136,14 +136,12 @@
return make_error<RawError>(raw_error_code::corrupt_file,
"DBI type server substream not aligned.");
- if (auto EC =
- Reader.readStreamRef(ModInfoSubstream, Header->ModiSubstreamSize))
- return EC;
-
// Since each ModInfo in the stream is a variable length, we have to iterate
// them to know how many there actually are.
- codeview::VarStreamArray ModInfoArray(ModInfoSubstream, ModInfoRecordLength);
- for (auto Info : ModInfoArray) {
+ codeview::VarStreamArray<ModInfo> ModInfoArray;
+ if (auto EC = Reader.readArray(ModInfoArray, Header->ModiSubstreamSize))
+ return EC;
+ for (auto &Info : ModInfoArray) {
ModuleInfos.emplace_back(Info);
}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp b/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp
index 9ccb7ed..67dc81d 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp
@@ -67,6 +67,8 @@
// Null terminated Obj File Name
};
+ModInfo::ModInfo() : Layout(nullptr) {}
+
ModInfo::ModInfo(codeview::StreamRef Stream) : Layout(nullptr) {
codeview::StreamReader Reader(Stream);
if (auto EC = Reader.readObject(Layout)) {
diff --git a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp
index 38d3f2f..404208a 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp
@@ -9,6 +9,7 @@
#include "llvm/DebugInfo/PDB/Raw/ModStream.h"
+#include "llvm/DebugInfo/CodeView/RecordIterator.h"
#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
@@ -32,8 +33,14 @@
return llvm::make_error<RawError>(raw_error_code::corrupt_file,
"Module has both C11 and C13 line info");
- if (auto EC = SymbolsSubstream.load(Reader, SymbolSize))
+ codeview::StreamRef S;
+
+ uint32_t SymbolSubstreamSig = 0;
+ if (auto EC = Reader.readInteger(SymbolSubstreamSig))
return EC;
+ if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4))
+ return EC;
+
if (auto EC = Reader.readStreamRef(LinesSubstream, C11Size))
return EC;
if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size))
@@ -51,6 +58,6 @@
return Error::success();
}
-iterator_range<codeview::SymbolIterator> ModStream::symbols() const {
- return codeview::makeSymbolRange(SymbolsSubstream.data().slice(4), nullptr);
+iterator_range<codeview::CVSymbolArray::Iterator> ModStream::symbols() const {
+ return llvm::make_range(SymbolsSubstream.begin(), SymbolsSubstream.end());
}