summaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-06-23 16:38:40 +0000
committerZachary Turner <zturner@google.com>2017-06-23 16:38:40 +0000
commit36e5ba3f322320f38ebceccbca2024ca3c3995e2 (patch)
tree08a4208726e1b8dffe9fe3ef5fe063958b877f7b /lib/Support
parentd9be98a70d9cd2cf4b1be1c2ce16115d1534a920 (diff)
Add a BinarySubstreamRef, and a method to read one.
This is essentially just a BinaryStreamRef packaged with an offset and the logic for reading one is no different than the logic for reading a BinaryStreamRef, except that we save the current offset. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306122 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/BinaryStreamReader.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Support/BinaryStreamReader.cpp b/lib/Support/BinaryStreamReader.cpp
index bfb658cfa0b7..e00527f2519e 100644
--- a/lib/Support/BinaryStreamReader.cpp
+++ b/lib/Support/BinaryStreamReader.cpp
@@ -109,6 +109,12 @@ Error BinaryStreamReader::readStreamRef(BinaryStreamRef &Ref, uint32_t Length) {
return Error::success();
}
+Error BinaryStreamReader::readSubstream(BinarySubstreamRef &Stream,
+ uint32_t Size) {
+ Stream.Offset = getOffset();
+ return readStreamRef(Stream.StreamData, Size);
+}
+
Error BinaryStreamReader::skip(uint32_t Amount) {
if (Amount > bytesRemaining())
return make_error<BinaryStreamError>(stream_error_code::stream_too_short);