aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-23 22:20:27 +0000
committerChris Lattner <sabre@nondot.org>2010-11-23 22:20:27 +0000
commit7cf705461cfdca5dd5b48a5065f8e24a1ce8c8c4 (patch)
tree748c87754359afa56af11389d94c0d8148be95ab /include/llvm
parent67ff104e7e42fe72ce0f20d6eeadb5ca5c45d119 (diff)
downloadexternal_llvm-7cf705461cfdca5dd5b48a5065f8e24a1ce8c8c4.tar.gz
external_llvm-7cf705461cfdca5dd5b48a5065f8e24a1ce8c8c4.tar.bz2
external_llvm-7cf705461cfdca5dd5b48a5065f8e24a1ce8c8c4.zip
add a MemoryBuffer::getOpenFile method, which turns an open
file descriptor into a MemoryBuffer (and closes the FD). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120065 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Support/MemoryBuffer.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h
index 41d4f88bfa..f29ddd1fea 100644
--- a/include/llvm/Support/MemoryBuffer.h
+++ b/include/llvm/Support/MemoryBuffer.h
@@ -60,13 +60,18 @@ public:
/// MemoryBuffer if successful, otherwise returning null. If FileSize is
/// specified, this means that the client knows that the file exists and that
/// it has the specified size.
- static MemoryBuffer *getFile(StringRef Filename,
- std::string *ErrStr = 0,
+ static MemoryBuffer *getFile(StringRef Filename, std::string *ErrStr = 0,
int64_t FileSize = -1);
- static MemoryBuffer *getFile(const char *Filename,
- std::string *ErrStr = 0,
+ static MemoryBuffer *getFile(const char *Filename, std::string *ErrStr = 0,
int64_t FileSize = -1);
+ /// getOpenFile - Given an already-open file descriptor, read the file and
+ /// return a MemoryBuffer. This takes ownership of the descriptor,
+ /// immediately closing it after reading the file.
+ static MemoryBuffer *getOpenFile(int FD, const char *Filename,
+ std::string *ErrStr = 0,
+ int64_t FileSize = -1);
+
/// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note
/// that InputData must be null terminated.
static MemoryBuffer *getMemBuffer(StringRef InputData,