diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-25 19:06:52 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-25 19:06:52 +0000 |
commit | 76a74f72534452b53ba3ba054bd8ab27efc48487 (patch) | |
tree | f0d039a2c0a3b24f73ea97eb204e16a380c318ac /lib | |
parent | a954618c6e6c5f94d3cedc0b6bc19dbc49e56ac2 (diff) | |
download | external_llvm-76a74f72534452b53ba3ba054bd8ab27efc48487.zip external_llvm-76a74f72534452b53ba3ba054bd8ab27efc48487.tar.gz external_llvm-76a74f72534452b53ba3ba054bd8ab27efc48487.tar.bz2 |
Change MemoryBuffer::getFile to take a Twine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193429 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Support/MemoryBuffer.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index 53437c8..dcd5529 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -238,14 +238,19 @@ static error_code getMemoryBufferForStream(int FD, return error_code::success(); } -error_code MemoryBuffer::getFile(StringRef Filename, +static error_code getFileAux(const char *Filename, + OwningPtr<MemoryBuffer> &result, int64_t FileSize, + bool RequiresNullTerminator); + +error_code MemoryBuffer::getFile(Twine Filename, OwningPtr<MemoryBuffer> &result, int64_t FileSize, bool RequiresNullTerminator) { // Ensure the path is null terminated. - SmallString<256> PathBuf(Filename.begin(), Filename.end()); - return MemoryBuffer::getFile(PathBuf.c_str(), result, FileSize, - RequiresNullTerminator); + SmallString<256> PathBuf; + StringRef NullTerminatedName = Filename.toNullTerminatedStringRef(PathBuf); + return getFileAux(NullTerminatedName.data(), result, FileSize, + RequiresNullTerminator); } static error_code getOpenFileImpl(int FD, const char *Filename, @@ -253,10 +258,9 @@ static error_code getOpenFileImpl(int FD, const char *Filename, uint64_t FileSize, uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator); -error_code MemoryBuffer::getFile(const char *Filename, - OwningPtr<MemoryBuffer> &result, - int64_t FileSize, - bool RequiresNullTerminator) { +static error_code getFileAux(const char *Filename, + OwningPtr<MemoryBuffer> &result, int64_t FileSize, + bool RequiresNullTerminator) { int FD; error_code EC = sys::fs::openFileForRead(Filename, FD); if (EC) |