summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/FileOutputBuffer.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-12-11 20:12:55 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-12-11 20:12:55 +0000
commit7eb1f1856c3b6549544256da9c4b881f695903cc (patch)
tree09f03a0f890d27db3e57ff0994cc13d82506c69f /llvm/lib/Support/FileOutputBuffer.cpp
parent01c73610d0fd4f12f19f44083437106957a737c4 (diff)
downloadbcm5719-llvm-7eb1f1856c3b6549544256da9c4b881f695903cc.tar.gz
bcm5719-llvm-7eb1f1856c3b6549544256da9c4b881f695903cc.zip
Remove a convoluted way of calling close by moving the call to the only caller.
As a bonus we can actually check the return value. llvm-svn: 224046
Diffstat (limited to 'llvm/lib/Support/FileOutputBuffer.cpp')
-rw-r--r--llvm/lib/Support/FileOutputBuffer.cpp11
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));
OpenPOWER on IntegriCloud