Mercurial > hg > CbC > CbC_llvm
diff include/llvm/Support/FileOutputBuffer.h @ 134:3a76565eade5 LLVM5.0.1
update 5.0.1
author | mir3636 |
---|---|
date | Sat, 17 Feb 2018 09:57:20 +0900 |
parents | 803732b1fca8 |
children | c2174574ed3a |
line wrap: on
line diff
--- a/include/llvm/Support/FileOutputBuffer.h Fri Feb 16 19:10:49 2018 +0900 +++ b/include/llvm/Support/FileOutputBuffer.h Sat Feb 17 09:57:20 2018 +0900 @@ -17,7 +17,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/ErrorOr.h" +#include "llvm/Support/Error.h" #include "llvm/Support/FileSystem.h" namespace llvm { @@ -30,7 +30,6 @@ /// not committed, the file will be deleted in the FileOutputBuffer destructor. class FileOutputBuffer { public: - enum { F_executable = 1 /// set the 'x' bit on the resulting file }; @@ -38,52 +37,37 @@ /// Factory method to create an OutputBuffer object which manages a read/write /// buffer of the specified size. When committed, the buffer will be written /// to the file at the specified path. - static ErrorOr<std::unique_ptr<FileOutputBuffer>> + static Expected<std::unique_ptr<FileOutputBuffer>> create(StringRef FilePath, size_t Size, unsigned Flags = 0); /// Returns a pointer to the start of the buffer. - uint8_t *getBufferStart() { - return (uint8_t*)Region->data(); - } + virtual uint8_t *getBufferStart() const = 0; /// Returns a pointer to the end of the buffer. - uint8_t *getBufferEnd() { - return (uint8_t*)Region->data() + Region->size(); - } + virtual uint8_t *getBufferEnd() const = 0; /// Returns size of the buffer. - size_t getBufferSize() const { - return Region->size(); - } + virtual size_t getBufferSize() const = 0; /// Returns path where file will show up if buffer is committed. - StringRef getPath() const { - return FinalPath; - } + StringRef getPath() const { return FinalPath; } /// Flushes the content of the buffer to its file and deallocates the /// buffer. If commit() is not called before this object's destructor /// is called, the file is deleted in the destructor. The optional parameter /// is used if it turns out you want the file size to be smaller than /// initially requested. - std::error_code commit(); + virtual Error commit() = 0; /// If this object was previously committed, the destructor just deletes /// this object. If this object was not committed, the destructor /// deallocates the buffer and the target file is never written. - ~FileOutputBuffer(); - -private: - FileOutputBuffer(const FileOutputBuffer &) = delete; - FileOutputBuffer &operator=(const FileOutputBuffer &) = delete; + virtual ~FileOutputBuffer() {} - FileOutputBuffer(std::unique_ptr<llvm::sys::fs::mapped_file_region> R, - StringRef Path, StringRef TempPath, bool IsRegular); +protected: + FileOutputBuffer(StringRef Path) : FinalPath(Path) {} - std::unique_ptr<llvm::sys::fs::mapped_file_region> Region; - SmallString<128> FinalPath; - SmallString<128> TempPath; - bool IsRegular; + std::string FinalPath; }; } // end namespace llvm