From 46225b193fd956545be97a83cecb4a3b6d3d6f17 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 16 Dec 2016 22:48:14 +0000 Subject: Resubmit "[CodeView] Hook CodeViewRecordIO for reading/writing symbols." The original patch was broken due to some undefined behavior as well as warnings that were triggering -Werror. llvm-svn: 290000 --- llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp') diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp index 19facaec9f0..9bd85cf9dc6 100644 --- a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -75,6 +75,16 @@ Error CodeViewRecordIO::mapByteVectorTail(ArrayRef &Bytes) { return Error::success(); } +Error CodeViewRecordIO::mapByteVectorTail(std::vector &Bytes) { + ArrayRef BytesRef(Bytes); + if (auto EC = mapByteVectorTail(BytesRef)) + return EC; + if (!isWriting()) + Bytes.assign(BytesRef.begin(), BytesRef.end()); + + return Error::success(); +} + Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) { if (isWriting()) { if (auto EC = Writer->writeInteger(TypeInd.getIndex())) @@ -160,6 +170,27 @@ Error CodeViewRecordIO::mapGuid(StringRef &Guid) { return Error::success(); } +Error CodeViewRecordIO::mapStringZVectorZ(std::vector &Value) { + if (isWriting()) { + for (auto V : Value) { + if (auto EC = mapStringZ(V)) + return EC; + } + if (auto EC = Writer->writeInteger(uint8_t(0))) + return EC; + } else { + StringRef S; + if (auto EC = mapStringZ(S)) + return EC; + while (!S.empty()) { + Value.push_back(S); + if (auto EC = mapStringZ(S)) + return EC; + }; + } + return Error::success(); +} + Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) { assert(Value < 0 && "Encoded integer is not signed!"); if (Value >= std::numeric_limits::min()) { -- cgit v1.2.3