diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 | 
| commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
| tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /include/llvm/Support/FileOutputBuffer.h | |
| parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) | |
Notes
Diffstat (limited to 'include/llvm/Support/FileOutputBuffer.h')
| -rw-r--r-- | include/llvm/Support/FileOutputBuffer.h | 38 | 
1 files changed, 11 insertions, 27 deletions
| diff --git a/include/llvm/Support/FileOutputBuffer.h b/include/llvm/Support/FileOutputBuffer.h index 2c054c75374b..6aed423a01e3 100644 --- a/include/llvm/Support/FileOutputBuffer.h +++ b/include/llvm/Support/FileOutputBuffer.h @@ -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 @@ namespace llvm {  /// 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 @@ public:    /// 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 | 
