diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-02 00:08:37 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-02 00:08:37 +0000 |
commit | 4e76019e349d1daab85cc42b265fbea1f9ff760c (patch) | |
tree | 2a7ceca6a3aae9eb25f86382cf0f200a97d9b1a2 | |
parent | 028eb5a3f823c25e6c3040d300910e23ed69e788 (diff) | |
download | bcm5719-llvm-4e76019e349d1daab85cc42b265fbea1f9ff760c.tar.gz bcm5719-llvm-4e76019e349d1daab85cc42b265fbea1f9ff760c.zip |
Support: Remove MemoryObject and DataStreamer interfaces.
These interfaces are no longer used.
Differential Revision: https://reviews.llvm.org/D26222
llvm-svn: 285774
-rw-r--r-- | llvm/include/llvm/Support/DataStream.h | 38 | ||||
-rw-r--r-- | llvm/include/llvm/Support/MemoryObject.h | 68 | ||||
-rw-r--r-- | llvm/include/llvm/Support/StreamingMemoryObject.h | 87 | ||||
-rw-r--r-- | llvm/lib/IR/GCOV.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Support/CMakeLists.txt | 3 | ||||
-rw-r--r-- | llvm/lib/Support/DataStream.cpp | 86 | ||||
-rw-r--r-- | llvm/lib/Support/MemoryObject.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Support/StreamingMemoryObject.cpp | 138 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h | 1 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp | 1 | ||||
-rw-r--r-- | llvm/unittests/Support/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/unittests/Support/StreamingMemoryObjectTest.cpp | 68 |
13 files changed, 0 insertions, 507 deletions
diff --git a/llvm/include/llvm/Support/DataStream.h b/llvm/include/llvm/Support/DataStream.h deleted file mode 100644 index a544316f430..00000000000 --- a/llvm/include/llvm/Support/DataStream.h +++ /dev/null @@ -1,38 +0,0 @@ -//===---- llvm/Support/DataStream.h - Lazy bitcode streaming ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This header defines DataStreamer, which fetches bytes of data from -// a stream source. It provides support for streaming (lazy reading) of -// data, e.g. bitcode -// -//===----------------------------------------------------------------------===// - - -#ifndef LLVM_SUPPORT_DATASTREAM_H -#define LLVM_SUPPORT_DATASTREAM_H - -#include <memory> -#include <string> - -namespace llvm { - -class DataStreamer { -public: - /// Fetch bytes [start-end) from the stream, and write them to the - /// buffer pointed to by buf. Returns the number of bytes actually written. - virtual size_t GetBytes(unsigned char *buf, size_t len) = 0; - - virtual ~DataStreamer(); -}; - -std::unique_ptr<DataStreamer> getDataFileStreamer(const std::string &Filename, - std::string *Err); -} - -#endif // LLVM_SUPPORT_DATASTREAM_H_ diff --git a/llvm/include/llvm/Support/MemoryObject.h b/llvm/include/llvm/Support/MemoryObject.h deleted file mode 100644 index e0c8749da34..00000000000 --- a/llvm/include/llvm/Support/MemoryObject.h +++ /dev/null @@ -1,68 +0,0 @@ -//===- MemoryObject.h - Abstract memory interface ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_MEMORYOBJECT_H -#define LLVM_SUPPORT_MEMORYOBJECT_H - -#include "llvm/Support/DataTypes.h" - -namespace llvm { - -/// Interface to data which might be streamed. Streamability has 2 important -/// implications/restrictions. First, the data might not yet exist in memory -/// when the request is made. This just means that readByte/readBytes might have -/// to block or do some work to get it. More significantly, the exact size of -/// the object might not be known until it has all been fetched. This means that -/// to return the right result, getExtent must also wait for all the data to -/// arrive; therefore it should not be called on objects which are actually -/// streamed (this would defeat the purpose of streaming). Instead, -/// isValidAddress can be used to test addresses without knowing the exact size -/// of the stream. Finally, getPointer can be used instead of readBytes to avoid -/// extra copying. -class MemoryObject { -public: - virtual ~MemoryObject(); - - /// Returns the size of the region in bytes. (The region is contiguous, so - /// the highest valid address of the region is getExtent() - 1). - /// - /// @result - The size of the region. - virtual uint64_t getExtent() const = 0; - - /// Tries to read a contiguous range of bytes from the region, up to the end - /// of the region. - /// - /// @param Buf - A pointer to a buffer to be filled in. Must be non-NULL - /// and large enough to hold size bytes. - /// @param Size - The number of bytes to copy. - /// @param Address - The address of the first byte, in the same space as - /// getBase(). - /// @result - The number of bytes read. - virtual uint64_t readBytes(uint8_t *Buf, uint64_t Size, - uint64_t Address) const = 0; - - /// Ensures that the requested data is in memory, and returns a pointer to it. - /// More efficient than using readBytes if the data is already in memory. May - /// block until (address - base + size) bytes have been read - /// @param address - address of the byte, in the same space as getBase() - /// @param size - amount of data that must be available on return - /// @result - valid pointer to the requested data - virtual const uint8_t *getPointer(uint64_t address, uint64_t size) const = 0; - - /// Returns true if the address is within the object (i.e. between base and - /// base + extent - 1 inclusive). May block until (address - base) bytes have - /// been read - /// @param address - address of the byte, in the same space as getBase() - /// @result - true if the address may be read with readByte() - virtual bool isValidAddress(uint64_t address) const = 0; -}; - -} - -#endif diff --git a/llvm/include/llvm/Support/StreamingMemoryObject.h b/llvm/include/llvm/Support/StreamingMemoryObject.h deleted file mode 100644 index 1ab85372cd2..00000000000 --- a/llvm/include/llvm/Support/StreamingMemoryObject.h +++ /dev/null @@ -1,87 +0,0 @@ -//===- StreamingMemoryObject.h - Streamable data interface -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_STREAMINGMEMORYOBJECT_H -#define LLVM_SUPPORT_STREAMINGMEMORYOBJECT_H - -#include "llvm/Support/Compiler.h" -#include "llvm/Support/DataStream.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/MemoryObject.h" -#include <memory> -#include <vector> - -namespace llvm { - -/// Interface to data which is actually streamed from a DataStreamer. In -/// addition to inherited members, it has the dropLeadingBytes and -/// setKnownObjectSize methods which are not applicable to non-streamed objects. -class StreamingMemoryObject : public MemoryObject { -public: - StreamingMemoryObject(std::unique_ptr<DataStreamer> Streamer); - uint64_t getExtent() const override; - uint64_t readBytes(uint8_t *Buf, uint64_t Size, - uint64_t Address) const override; - const uint8_t *getPointer(uint64_t Address, uint64_t Size) const override; - bool isValidAddress(uint64_t address) const override; - - /// Drop s bytes from the front of the stream, pushing the positions of the - /// remaining bytes down by s. This is used to skip past the bitcode header, - /// since we don't know a priori if it's present, and we can't put bytes - /// back into the stream once we've read them. - bool dropLeadingBytes(size_t s); - - /// If the data object size is known in advance, many of the operations can - /// be made more efficient, so this method should be called before reading - /// starts (although it can be called anytime). - void setKnownObjectSize(size_t size); - - /// The number of bytes read at a time from the data streamer. - static const uint32_t kChunkSize = 4096 * 4; - -private: - mutable std::vector<unsigned char> Bytes; - std::unique_ptr<DataStreamer> Streamer; - mutable size_t BytesRead; // Bytes read from stream - size_t BytesSkipped;// Bytes skipped at start of stream (e.g. wrapper/header) - mutable size_t ObjectSize; // 0 if unknown, set if wrapper seen or EOF reached - mutable bool EOFReached; - - // Fetch enough bytes such that Pos can be read (i.e. BytesRead > - // Pos). Returns true if Pos can be read. Unlike most of the - // functions in BitcodeReader, returns true on success. Most of the - // requests will be small, but we fetch at kChunkSize bytes at a - // time to avoid making too many potentially expensive GetBytes - // calls. - bool fetchToPos(size_t Pos) const { - while (Pos >= BytesRead) { - if (EOFReached) - return false; - Bytes.resize(BytesRead + BytesSkipped + kChunkSize); - size_t bytes = Streamer->GetBytes(&Bytes[BytesRead + BytesSkipped], - kChunkSize); - BytesRead += bytes; - if (bytes == 0) { // reached EOF/ran out of bytes - if (ObjectSize == 0) - ObjectSize = BytesRead; - EOFReached = true; - } - } - return !ObjectSize || Pos < ObjectSize; - } - - StreamingMemoryObject(const StreamingMemoryObject&) = delete; - void operator=(const StreamingMemoryObject&) = delete; -}; - -MemoryObject *getNonStreamedMemoryObject( - const unsigned char *Start, const unsigned char *End); - -} -#endif // STREAMINGMEMORYOBJECT_H_ diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp index a9f7f45ee30..3bbcf781e5d 100644 --- a/llvm/lib/IR/GCOV.cpp +++ b/llvm/lib/IR/GCOV.cpp @@ -17,7 +17,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" -#include "llvm/Support/MemoryObject.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt index d8ecfa9b862..5b14c828db0 100644 --- a/llvm/lib/Support/CMakeLists.txt +++ b/llvm/lib/Support/CMakeLists.txt @@ -45,7 +45,6 @@ add_llvm_library(LLVMSupport ConvertUTFWrapper.cpp CrashRecoveryContext.cpp DataExtractor.cpp - DataStream.cpp Debug.cpp DeltaAlgorithm.cpp DAGDeltaAlgorithm.cpp @@ -69,7 +68,6 @@ add_llvm_library(LLVMSupport ManagedStatic.cpp MathExtras.cpp MemoryBuffer.cpp - MemoryObject.cpp MD5.cpp NativeFormatting.cpp Options.cpp @@ -85,7 +83,6 @@ add_llvm_library(LLVMSupport SourceMgr.cpp SpecialCaseList.cpp Statistic.cpp - StreamingMemoryObject.cpp StringExtras.cpp StringMap.cpp StringPool.cpp diff --git a/llvm/lib/Support/DataStream.cpp b/llvm/lib/Support/DataStream.cpp deleted file mode 100644 index 3b10fc5eeca..00000000000 --- a/llvm/lib/Support/DataStream.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===--- llvm/Support/DataStream.cpp - Lazy streamed data -----------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements DataStreamer, which fetches bytes of Data from -// a stream source. It provides support for streaming (lazy reading) of -// bitcode. An example implementation of streaming from a file or stdin -// is included. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/DataStream.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/Program.h" -#include <string> -#include <system_error> -#if !defined(_MSC_VER) && !defined(__MINGW32__) -#include <unistd.h> -#else -#include <io.h> -#endif -using namespace llvm; - -#define DEBUG_TYPE "Data-stream" - -// Interface goals: -// * StreamingMemoryObject doesn't care about complexities like using -// threads/async callbacks to actually overlap download+compile -// * Don't want to duplicate Data in memory -// * Don't need to know total Data len in advance -// Non-goals: -// StreamingMemoryObject already has random access so this interface only does -// in-order streaming (no arbitrary seeking, else we'd have to buffer all the -// Data here in addition to MemoryObject). This also means that if we want -// to be able to to free Data, BitstreamBytes/BitcodeReader will implement it - -STATISTIC(NumStreamFetches, "Number of calls to Data stream fetch"); - -namespace llvm { -DataStreamer::~DataStreamer() {} -} - -namespace { - -// Very simple stream backed by a file. Mostly useful for stdin and debugging; -// actual file access is probably still best done with mmap. -class DataFileStreamer : public DataStreamer { - int Fd; -public: - DataFileStreamer() : Fd(0) {} - ~DataFileStreamer() override { close(Fd); } - size_t GetBytes(unsigned char *buf, size_t len) override { - NumStreamFetches++; - return read(Fd, buf, len); - } - - std::error_code OpenFile(const std::string &Filename) { - if (Filename == "-") { - Fd = 0; - sys::ChangeStdinToBinary(); - return std::error_code(); - } - - return sys::fs::openFileForRead(Filename, Fd); - } -}; - -} - -std::unique_ptr<DataStreamer> -llvm::getDataFileStreamer(const std::string &Filename, std::string *StrError) { - std::unique_ptr<DataFileStreamer> s = make_unique<DataFileStreamer>(); - if (std::error_code e = s->OpenFile(Filename)) { - *StrError = std::string("Could not open ") + Filename + ": " + - e.message() + "\n"; - return nullptr; - } - return std::move(s); -} diff --git a/llvm/lib/Support/MemoryObject.cpp b/llvm/lib/Support/MemoryObject.cpp deleted file mode 100644 index d796acfa90e..00000000000 --- a/llvm/lib/Support/MemoryObject.cpp +++ /dev/null @@ -1,14 +0,0 @@ -//===- MemoryObject.cpp - Abstract memory interface -----------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/MemoryObject.h" -using namespace llvm; - -MemoryObject::~MemoryObject() { -} diff --git a/llvm/lib/Support/StreamingMemoryObject.cpp b/llvm/lib/Support/StreamingMemoryObject.cpp deleted file mode 100644 index fb566179486..00000000000 --- a/llvm/lib/Support/StreamingMemoryObject.cpp +++ /dev/null @@ -1,138 +0,0 @@ -//===- StreamingMemoryObject.cpp - Streamable data interface -------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/StreamingMemoryObject.h" -#include <cassert> -#include <cstddef> -#include <cstring> -using namespace llvm; - -namespace { - -class RawMemoryObject : public MemoryObject { -public: - RawMemoryObject(const unsigned char *Start, const unsigned char *End) : - FirstChar(Start), LastChar(End) { - assert(LastChar >= FirstChar && "Invalid start/end range"); - } - - uint64_t getExtent() const override { - return LastChar - FirstChar; - } - uint64_t readBytes(uint8_t *Buf, uint64_t Size, - uint64_t Address) const override; - const uint8_t *getPointer(uint64_t address, uint64_t size) const override; - bool isValidAddress(uint64_t address) const override { - return validAddress(address); - } - -private: - const uint8_t* const FirstChar; - const uint8_t* const LastChar; - - // These are implemented as inline functions here to avoid multiple virtual - // calls per public function - bool validAddress(uint64_t address) const { - return static_cast<std::ptrdiff_t>(address) < LastChar - FirstChar; - } - - RawMemoryObject(const RawMemoryObject&) = delete; - void operator=(const RawMemoryObject&) = delete; -}; - -uint64_t RawMemoryObject::readBytes(uint8_t *Buf, uint64_t Size, - uint64_t Address) const { - uint64_t BufferSize = LastChar - FirstChar; - if (Address >= BufferSize) - return 0; - - uint64_t End = Address + Size; - if (End > BufferSize) - End = BufferSize; - - assert(static_cast<int64_t>(End - Address) >= 0); - Size = End - Address; - memcpy(Buf, Address + FirstChar, Size); - return Size; -} - -const uint8_t *RawMemoryObject::getPointer(uint64_t address, - uint64_t size) const { - return FirstChar + address; -} -} // anonymous namespace - -namespace llvm { -// If the bitcode has a header, then its size is known, and we don't have to -// block until we actually want to read it. -bool StreamingMemoryObject::isValidAddress(uint64_t address) const { - if (ObjectSize && address < ObjectSize) return true; - return fetchToPos(address); -} - -uint64_t StreamingMemoryObject::getExtent() const { - if (ObjectSize) return ObjectSize; - size_t pos = BytesRead + kChunkSize; - // keep fetching until we run out of bytes - while (fetchToPos(pos)) pos += kChunkSize; - return ObjectSize; -} - -uint64_t StreamingMemoryObject::readBytes(uint8_t *Buf, uint64_t Size, - uint64_t Address) const { - fetchToPos(Address + Size - 1); - // Note: For wrapped bitcode files will set ObjectSize after the - // first call to fetchToPos. In such cases, ObjectSize can be - // smaller than BytesRead. - size_t MaxAddress = - (ObjectSize && ObjectSize < BytesRead) ? ObjectSize : BytesRead; - if (Address >= MaxAddress) - return 0; - - uint64_t End = Address + Size; - if (End > MaxAddress) - End = MaxAddress; - assert(End >= Address); - Size = End - Address; - memcpy(Buf, &Bytes[Address + BytesSkipped], Size); - return Size; -} - -const uint8_t *StreamingMemoryObject::getPointer(uint64_t Address, - uint64_t Size) const { - fetchToPos(Address + Size - 1); - return &Bytes[Address + BytesSkipped]; -} - -bool StreamingMemoryObject::dropLeadingBytes(size_t s) { - if (BytesRead < s) return true; - BytesSkipped = s; - BytesRead -= s; - return false; -} - -void StreamingMemoryObject::setKnownObjectSize(size_t size) { - ObjectSize = size; - Bytes.reserve(size); - if (ObjectSize <= BytesRead) - EOFReached = true; -} - -MemoryObject *getNonStreamedMemoryObject(const unsigned char *Start, - const unsigned char *End) { - return new RawMemoryObject(Start, End); -} - -StreamingMemoryObject::StreamingMemoryObject( - std::unique_ptr<DataStreamer> Streamer) - : Bytes(kChunkSize), Streamer(std::move(Streamer)), BytesRead(0), - BytesSkipped(0), ObjectSize(0), EOFReached(false) { - BytesRead = this->Streamer->GetBytes(&Bytes[0], kChunkSize); -} -} diff --git a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h index e475e505e7d..24e353cf4b9 100644 --- a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h +++ b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h @@ -18,7 +18,6 @@ namespace llvm { class MCInst; -class MemoryObject; class raw_ostream; class AArch64Disassembler : public MCDisassembler { diff --git a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp index a65522cb14a..92c20365fe0 100644 --- a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp +++ b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp @@ -27,7 +27,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/LEB128.h" -#include "llvm/Support/MemoryObject.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/TargetRegistry.h" diff --git a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp index 82ef48e216e..609b650e5d3 100644 --- a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp +++ b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp @@ -19,7 +19,6 @@ #include "llvm/MC/MCInst.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Support/MemoryObject.h" #include "llvm/Support/TargetRegistry.h" using namespace llvm; diff --git a/llvm/unittests/Support/CMakeLists.txt b/llvm/unittests/Support/CMakeLists.txt index daf6524acf6..695f157140a 100644 --- a/llvm/unittests/Support/CMakeLists.txt +++ b/llvm/unittests/Support/CMakeLists.txt @@ -38,7 +38,6 @@ add_llvm_unittest(SupportTests ScaledNumberTest.cpp SourceMgrTest.cpp SpecialCaseListTest.cpp - StreamingMemoryObjectTest.cpp StringPool.cpp SwapByteOrderTest.cpp TargetParserTest.cpp diff --git a/llvm/unittests/Support/StreamingMemoryObjectTest.cpp b/llvm/unittests/Support/StreamingMemoryObjectTest.cpp deleted file mode 100644 index 836dfa9084f..00000000000 --- a/llvm/unittests/Support/StreamingMemoryObjectTest.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//===- unittests/Support/StreamingMemoryObjectTest.cpp --------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/StreamingMemoryObject.h" -#include "gtest/gtest.h" -#include <string.h> - -using namespace llvm; - -namespace { - -class NullDataStreamer : public DataStreamer { - size_t GetBytes(unsigned char *Buffer, size_t Length) override { - memset(Buffer, 0, Length); - return Length; - } -}; - -class BufferStreamer : public DataStreamer { - StringRef Buffer; - -public: - BufferStreamer(StringRef Buffer) : Buffer(Buffer) {} - size_t GetBytes(unsigned char *OutBuffer, size_t Length) override { - if (Length >= Buffer.size()) - Length = Buffer.size(); - - std::copy(Buffer.begin(), Buffer.begin() + Length, OutBuffer); - Buffer = Buffer.drop_front(Length); - return Length; - } -}; - -TEST(StreamingMemoryObjectTest, isValidAddress) { - auto DS = make_unique<NullDataStreamer>(); - StreamingMemoryObject O(std::move(DS)); - EXPECT_TRUE(O.isValidAddress(32 * 1024)); -} - -TEST(StreamingMemoryObjectTest, setKnownObjectSize) { - auto DS = make_unique<NullDataStreamer>(); - StreamingMemoryObject O(std::move(DS)); - uint8_t Buf[32]; - EXPECT_EQ(16u, O.readBytes(Buf, 16, 0)); - O.setKnownObjectSize(24); - EXPECT_EQ(8u, O.readBytes(Buf, 16, 16)); -} - -TEST(StreamingMemoryObjectTest, getPointer) { - uint8_t InputBuffer[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; - StreamingMemoryObject O(make_unique<BufferStreamer>(StringRef( - reinterpret_cast<const char *>(InputBuffer), sizeof(InputBuffer)))); - - EXPECT_TRUE(std::equal(InputBuffer + 1, InputBuffer + 2, O.getPointer(1, 2))); - EXPECT_TRUE(std::equal(InputBuffer + 3, InputBuffer + 7, O.getPointer(3, 4))); - EXPECT_TRUE(std::equal(InputBuffer + 4, InputBuffer + 8, O.getPointer(4, 5))); - EXPECT_TRUE(std::equal(InputBuffer, InputBuffer + 8, O.getPointer(0, 20))); -} - -} // end namespace |