diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-05 22:42:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-05 22:42:30 +0000 |
commit | 4c842dda3939c6b9f83ba7e8e19e43445cd9a832 (patch) | |
tree | d3d4dd38475faa8e3bea9c995f993b662b688df9 /lib/Support | |
parent | da72249ecbfcaa6c8d81e9798812283b8a9947ed (diff) | |
download | external_llvm-4c842dda3939c6b9f83ba7e8e19e43445cd9a832.zip external_llvm-4c842dda3939c6b9f83ba7e8e19e43445cd9a832.tar.gz external_llvm-4c842dda3939c6b9f83ba7e8e19e43445cd9a832.tar.bz2 |
stringref-ize the MemoryBuffer::get apis. This requires
a co-committed clang patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100485 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/MemoryBuffer.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index 4f135ea..2b95089 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -71,13 +71,12 @@ namespace { class MemoryBufferMem : public MemoryBuffer { std::string FileID; public: - MemoryBufferMem(const char *Start, const char *End, StringRef FID, - bool Copy = false) + MemoryBufferMem(StringRef InputData, StringRef FID, bool Copy = false) : FileID(FID) { if (!Copy) - init(Start, End); + init(InputData.data(), InputData.data()+InputData.size()); else - initCopyOf(Start, End); + initCopyOf(InputData.data(), InputData.data()+InputData.size()); } virtual const char *getBufferIdentifier() const { @@ -88,19 +87,17 @@ public: /// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note /// that EndPtr[0] must be a null byte and be accessible! -MemoryBuffer *MemoryBuffer::getMemBuffer(const char *StartPtr, - const char *EndPtr, +MemoryBuffer *MemoryBuffer::getMemBuffer(StringRef InputData, const char *BufferName) { - return new MemoryBufferMem(StartPtr, EndPtr, BufferName); + return new MemoryBufferMem(InputData, BufferName); } /// getMemBufferCopy - Open the specified memory range as a MemoryBuffer, /// copying the contents and taking ownership of it. This has no requirements /// on EndPtr[0]. -MemoryBuffer *MemoryBuffer::getMemBufferCopy(const char *StartPtr, - const char *EndPtr, +MemoryBuffer *MemoryBuffer::getMemBufferCopy(StringRef InputData, const char *BufferName) { - return new MemoryBufferMem(StartPtr, EndPtr, BufferName, true); + return new MemoryBufferMem(InputData, BufferName, true); } /// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size @@ -112,7 +109,7 @@ MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size, char *Buf = (char *)malloc(Size+1); if (!Buf) return 0; Buf[Size] = 0; - MemoryBufferMem *SB = new MemoryBufferMem(Buf, Buf+Size, BufferName); + MemoryBufferMem *SB = new MemoryBufferMem(StringRef(Buf, Size), BufferName); // The memory for this buffer is owned by the MemoryBuffer. SB->MustDeleteBuffer = true; return SB; |