diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-02-08 22:40:47 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-02-08 22:40:47 +0000 |
commit | 56e41f7f0b0a421ea1d236ed6496b8db26f803ef (patch) | |
tree | dfa62b21f25cc0c13652c66a40922a99e60bf42f /llvm/lib/Support | |
parent | 4ebf471c9b8a30905692eda8908107aa5e08ce8e (diff) | |
download | bcm5719-llvm-56e41f7f0b0a421ea1d236ed6496b8db26f803ef.tar.gz bcm5719-llvm-56e41f7f0b0a421ea1d236ed6496b8db26f803ef.zip |
Don't open the file again in the gold plugin. To be able to do this, update
MemoryBuffer::getOpenFile to not close the file descriptor.
llvm-svn: 125128
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/MemoryBuffer.cpp | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp index b7d70dd603d..a0c650d6820 100644 --- a/llvm/lib/Support/MemoryBuffer.cpp +++ b/llvm/lib/Support/MemoryBuffer.cpp @@ -179,14 +179,6 @@ public: sys::Path::UnMapFilePages(getBufferStart(), getBufferSize()); } }; - -/// FileCloser - RAII object to make sure an FD gets closed properly. -class FileCloser { - int FD; -public: - explicit FileCloser(int FD) : FD(FD) {} - ~FileCloser() { ::close(FD); } -}; } error_code MemoryBuffer::getFile(StringRef Filename, @@ -208,15 +200,14 @@ error_code MemoryBuffer::getFile(const char *Filename, if (FD == -1) { return error_code(errno, posix_category()); } - - return getOpenFile(FD, Filename, result, FileSize); + error_code ret = getOpenFile(FD, Filename, result, FileSize); + close(FD); + return ret; } error_code MemoryBuffer::getOpenFile(int FD, const char *Filename, OwningPtr<MemoryBuffer> &result, int64_t FileSize) { - FileCloser FC(FD); // Close FD on return. - // If we don't know the file size, use fstat to find out. fstat on an open // file descriptor is cheaper than stat on a random path. if (FileSize == -1) { |