summaryrefslogtreecommitdiff
path: root/include/llvm/Support/MemoryBuffer.h
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-07-23 20:25:01 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-07-23 20:25:01 +0000
commit70c7e485453fdbc228406715556f9447bc9f9fd8 (patch)
tree4125c10ac177c7fde6e17b89be28539ddc3ec486 /include/llvm/Support/MemoryBuffer.h
parent963cf75e1cf9a87f0f571919d06adcbf60edd377 (diff)
downloadllvm-70c7e485453fdbc228406715556f9447bc9f9fd8.tar.gz
llvm-70c7e485453fdbc228406715556f9447bc9f9fd8.tar.bz2
llvm-70c7e485453fdbc228406715556f9447bc9f9fd8.tar.xz
Split getOpenFile into getOpenFile and getOpenFileSlice.
The main observation is that we never need both the filesize and the map size. When mapping a slice of a file, it doesn't make sense to request a null terminator and that would be the only case where the filesize would be used. There are other cleanups that should be done in this area: * A client should not have to pass the size (even an explicit -1) to say if it wants a null terminator or not, so we should probably swap the argument order. * The default should be to not require a null terminator. Very few clients require this, but many end up asking for it just because it is the default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186984 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/MemoryBuffer.h')
-rw-r--r--include/llvm/Support/MemoryBuffer.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h
index e443b68463..9609e3366d 100644
--- a/include/llvm/Support/MemoryBuffer.h
+++ b/include/llvm/Support/MemoryBuffer.h
@@ -74,13 +74,17 @@ public:
int64_t FileSize = -1,
bool RequiresNullTerminator = true);
- /// getOpenFile - Given an already-open file descriptor, read the file and
- /// return a MemoryBuffer.
+ // Get a MemoryBuffer of part of a file. Since this is in the middle of a
+ // file, the buffer is not null terminated.
+ static error_code getOpenFileSlice(int FD, const char *Filename,
+ OwningPtr<MemoryBuffer> &Result,
+ uint64_t MapSize, int64_t Offset);
+
+ /// Given an already-open file descriptor, read the file and return a
+ /// MemoryBuffer.
static error_code getOpenFile(int FD, const char *Filename,
- OwningPtr<MemoryBuffer> &result,
- uint64_t FileSize = -1,
- uint64_t MapSize = -1,
- int64_t Offset = 0,
+ OwningPtr<MemoryBuffer> &Result,
+ uint64_t FileSize,
bool RequiresNullTerminator = true);
/// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note