diff options
Diffstat (limited to 'llvm/lib/Support/FileOutputBuffer.cpp')
-rw-r--r-- | llvm/lib/Support/FileOutputBuffer.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Support/FileOutputBuffer.cpp b/llvm/lib/Support/FileOutputBuffer.cpp index c62655d58d5..57a0f60d277 100644 --- a/llvm/lib/Support/FileOutputBuffer.cpp +++ b/llvm/lib/Support/FileOutputBuffer.cpp @@ -18,6 +18,12 @@ #include "llvm/Support/raw_ostream.h" #include <system_error> +#if !defined(_MSC_VER) && !defined(__MINGW32__) +#include <unistd.h> +#else +#include <io.h> +#endif + using llvm::sys::fs::mapped_file_region; namespace llvm { @@ -72,9 +78,12 @@ FileOutputBuffer::create(StringRef FilePath, size_t Size, return EC; auto MappedFile = llvm::make_unique<mapped_file_region>( - FD, true, mapped_file_region::readwrite, Size, 0, EC); + FD, mapped_file_region::readwrite, Size, 0, EC); + int Ret = close(FD); if (EC) return EC; + if (Ret) + return std::error_code(errno, std::generic_category()); Result.reset( new FileOutputBuffer(std::move(MappedFile), FilePath, TempFilePath)); |