diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-11-08 01:05:44 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-11-08 01:05:44 +0000 |
commit | e0df357dbdd69e8e0bd3c211a4cc099b084d999f (patch) | |
tree | dd1df35bcf54715680e2665f7fd8c37e6f26f48a /llvm/lib/Support/FileOutputBuffer.cpp | |
parent | b8c9e2aae5dff204f41646565bda778725e085b6 (diff) | |
download | bcm5719-llvm-e0df357dbdd69e8e0bd3c211a4cc099b084d999f.tar.gz bcm5719-llvm-e0df357dbdd69e8e0bd3c211a4cc099b084d999f.zip |
Convert FileOutputBuffer to Expected. NFC.
llvm-svn: 317649
Diffstat (limited to 'llvm/lib/Support/FileOutputBuffer.cpp')
-rw-r--r-- | llvm/lib/Support/FileOutputBuffer.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Support/FileOutputBuffer.cpp b/llvm/lib/Support/FileOutputBuffer.cpp index 1e20b01fc4a..d81541b43d7 100644 --- a/llvm/lib/Support/FileOutputBuffer.cpp +++ b/llvm/lib/Support/FileOutputBuffer.cpp @@ -38,7 +38,7 @@ public: std::unique_ptr<fs::mapped_file_region> Buf) : FileOutputBuffer(Path), Buffer(std::move(Buf)), TempPath(TempPath) {} - static ErrorOr<std::unique_ptr<OnDiskBuffer>> + static Expected<std::unique_ptr<OnDiskBuffer>> create(StringRef Path, size_t Size, unsigned Mode); uint8_t *getBufferStart() const override { return (uint8_t *)Buffer->data(); } @@ -78,13 +78,13 @@ public: InMemoryBuffer(StringRef Path, MemoryBlock Buf, unsigned Mode) : FileOutputBuffer(Path), Buffer(Buf), Mode(Mode) {} - static ErrorOr<std::unique_ptr<InMemoryBuffer>> + static Expected<std::unique_ptr<InMemoryBuffer>> create(StringRef Path, size_t Size, unsigned Mode) { std::error_code EC; MemoryBlock MB = Memory::allocateMappedMemory( Size, nullptr, sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC); if (EC) - return EC; + return errorCodeToError(EC); return llvm::make_unique<InMemoryBuffer>(Path, MB, Mode); } @@ -111,13 +111,13 @@ private: unsigned Mode; }; -ErrorOr<std::unique_ptr<OnDiskBuffer>> +Expected<std::unique_ptr<OnDiskBuffer>> OnDiskBuffer::create(StringRef Path, size_t Size, unsigned Mode) { // Create new file in same directory but with random name. SmallString<128> TempPath; int FD; if (auto EC = fs::createUniqueFile(Path + ".tmp%%%%%%%", FD, TempPath, Mode)) - return EC; + return errorCodeToError(EC); sys::RemoveFileOnSignal(TempPath); @@ -128,7 +128,7 @@ OnDiskBuffer::create(StringRef Path, size_t Size, unsigned Mode) { // pretty slow just like it writes specified amount of bytes, // so we should avoid calling that function. if (auto EC = fs::resize_file(FD, Size)) - return EC; + return errorCodeToError(EC); #endif // Mmap it. @@ -137,12 +137,12 @@ OnDiskBuffer::create(StringRef Path, size_t Size, unsigned Mode) { FD, fs::mapped_file_region::readwrite, Size, 0, EC); close(FD); if (EC) - return EC; + return errorCodeToError(EC); return llvm::make_unique<OnDiskBuffer>(Path, TempPath, std::move(MappedFile)); } // Create an instance of FileOutputBuffer. -ErrorOr<std::unique_ptr<FileOutputBuffer>> +Expected<std::unique_ptr<FileOutputBuffer>> FileOutputBuffer::create(StringRef Path, size_t Size, unsigned Flags) { unsigned Mode = fs::all_read | fs::all_write; if (Flags & F_executable) @@ -161,7 +161,7 @@ FileOutputBuffer::create(StringRef Path, size_t Size, unsigned Flags) { // destination file and write to it on commit(). switch (Stat.type()) { case fs::file_type::directory_file: - return errc::is_a_directory; + return errorCodeToError(errc::is_a_directory); case fs::file_type::regular_file: case fs::file_type::file_not_found: case fs::file_type::status_error: |