diff options
author | Ahmed Charles <ahmedcharles@gmail.com> | 2014-03-05 10:27:34 +0000 |
---|---|---|
committer | Ahmed Charles <ahmedcharles@gmail.com> | 2014-03-05 10:27:34 +0000 |
commit | fbf6daaec64cced33b5b4e944ef4804ad79d76c2 (patch) | |
tree | 4ccdd8285c6cba6f1216cab860a714d04d37962c /include/llvm/Support | |
parent | 2e816f0d562294c82b9fb31762371c59654c71e1 (diff) | |
download | llvm-fbf6daaec64cced33b5b4e944ef4804ad79d76c2.tar.gz llvm-fbf6daaec64cced33b5b4e944ef4804ad79d76c2.tar.bz2 llvm-fbf6daaec64cced33b5b4e944ef4804ad79d76c2.tar.xz |
[C++11] Add overloads for externally used OwningPtr functions.
This will allow external callers of these functions to switch over time
rather than forcing a breaking change all a once. These particular
functions were determined by building clang/lld/lldb.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202959 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r-- | include/llvm/Support/FileOutputBuffer.h | 5 | ||||
-rw-r--r-- | include/llvm/Support/MemoryBuffer.h | 22 |
2 files changed, 23 insertions, 4 deletions
diff --git a/include/llvm/Support/FileOutputBuffer.h b/include/llvm/Support/FileOutputBuffer.h index cbc9c467d2..1884a242b3 100644 --- a/include/llvm/Support/FileOutputBuffer.h +++ b/include/llvm/Support/FileOutputBuffer.h @@ -43,6 +43,9 @@ public: static error_code create(StringRef FilePath, size_t Size, OwningPtr<FileOutputBuffer> &Result, unsigned Flags = 0); + static error_code create(StringRef FilePath, size_t Size, + std::unique_ptr<FileOutputBuffer> &Result, + unsigned Flags = 0); /// Returns a pointer to the start of the buffer. uint8_t *getBufferStart() { @@ -83,7 +86,7 @@ private: FileOutputBuffer(llvm::sys::fs::mapped_file_region *R, StringRef Path, StringRef TempPath); - OwningPtr<llvm::sys::fs::mapped_file_region> Region; + std::unique_ptr<llvm::sys::fs::mapped_file_region> Region; SmallString<128> FinalPath; SmallString<128> TempPath; }; diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index ea10a70f09..1910d44240 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -19,6 +19,7 @@ #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" +#include <memory> namespace llvm { @@ -66,7 +67,11 @@ 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 error_code getFile(Twine Filename, OwningPtr<MemoryBuffer> &result, + static error_code getFile(Twine Filename, OwningPtr<MemoryBuffer> &Result, + int64_t FileSize = -1, + bool RequiresNullTerminator = true); + static error_code getFile(Twine Filename, + std::unique_ptr<MemoryBuffer> &Result, int64_t FileSize = -1, bool RequiresNullTerminator = true); @@ -76,6 +81,9 @@ public: static error_code getOpenFileSlice(int FD, const char *Filename, OwningPtr<MemoryBuffer> &Result, uint64_t MapSize, int64_t Offset); + static error_code getOpenFileSlice(int FD, const char *Filename, + std::unique_ptr<MemoryBuffer> &Result, + uint64_t MapSize, int64_t Offset); /// Given an already-open file descriptor, read the file and return a /// MemoryBuffer. @@ -83,6 +91,10 @@ public: OwningPtr<MemoryBuffer> &Result, uint64_t FileSize, bool RequiresNullTerminator = true); + static error_code getOpenFile(int FD, const char *Filename, + std::unique_ptr<MemoryBuffer> &Result, + uint64_t FileSize, + bool RequiresNullTerminator = true); /// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note /// that InputData must be null terminated if RequiresNullTerminator is true. @@ -111,14 +123,18 @@ public: /// getSTDIN - Read all of stdin into a file buffer, and return it. /// If an error occurs, this returns null and sets ec. - static error_code getSTDIN(OwningPtr<MemoryBuffer> &result); + static error_code getSTDIN(OwningPtr<MemoryBuffer> &Result); + static error_code getSTDIN(std::unique_ptr<MemoryBuffer> &Result); /// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin /// if the Filename is "-". If an error occurs, this returns null and sets /// ec. static error_code getFileOrSTDIN(StringRef Filename, - OwningPtr<MemoryBuffer> &result, + OwningPtr<MemoryBuffer> &Result, + int64_t FileSize = -1); + static error_code getFileOrSTDIN(StringRef Filename, + std::unique_ptr<MemoryBuffer> &Result, int64_t FileSize = -1); //===--------------------------------------------------------------------===// |