projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Removed white-space
[oota-llvm.git]
/
lib
/
Support
/
FileOutputBuffer.cpp
diff --git
a/lib/Support/FileOutputBuffer.cpp
b/lib/Support/FileOutputBuffer.cpp
index 68f6fa16f965bc8d62e554e2133782ba10cbbb6d..c62655d58d5fa16f564c710008eb4b1dc3bb3b90 100644
(file)
--- a/
lib/Support/FileOutputBuffer.cpp
+++ b/
lib/Support/FileOutputBuffer.cpp
@@
-11,33
+11,31
@@
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/Errc.h"
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <system_error>
using llvm::sys::fs::mapped_file_region;
#include "llvm/Support/raw_ostream.h"
#include <system_error>
using llvm::sys::fs::mapped_file_region;
-using std::error_code;
namespace llvm {
namespace llvm {
-FileOutputBuffer::FileOutputBuffer(
mapped_file_region *
R,
+FileOutputBuffer::FileOutputBuffer(
std::unique_ptr<mapped_file_region>
R,
StringRef Path, StringRef TmpPath)
StringRef Path, StringRef TmpPath)
- : Region(R)
- , FinalPath(Path)
- , TempPath(TmpPath) {
-}
+ : Region(std::move(R)), FinalPath(Path), TempPath(TmpPath) {}
FileOutputBuffer::~FileOutputBuffer() {
sys::fs::remove(Twine(TempPath));
}
FileOutputBuffer::~FileOutputBuffer() {
sys::fs::remove(Twine(TempPath));
}
-error_code FileOutputBuffer::create(StringRef FilePath,
-
size_t Size,
-
std::unique_ptr<FileOutputBuffer> &Result,
-
unsigned Flags) {
+std::error_code
+
FileOutputBuffer::create(StringRef FilePath,
size_t Size,
+ std::unique_ptr<FileOutputBuffer> &Result,
+ unsigned Flags) {
// If file already exists, it must be a regular file (to be mappable).
sys::fs::file_status Stat;
// If file already exists, it must be a regular file (to be mappable).
sys::fs::file_status Stat;
- error_code EC = sys::fs::status(FilePath, Stat);
+
std::
error_code EC = sys::fs::status(FilePath, Stat);
switch (Stat.type()) {
case sys::fs::file_type::file_not_found:
// If file does not exist, we'll create one.
switch (Stat.type()) {
case sys::fs::file_type::file_not_found:
// If file does not exist, we'll create one.
@@
-52,7
+50,7
@@
error_code FileOutputBuffer::create(StringRef FilePath,
if (EC)
return EC;
else
if (EC)
return EC;
else
- return
std::make_error_code(std::
errc::operation_not_permitted);
+ return
make_error_code(
errc::operation_not_permitted);
}
// Delete target file.
}
// Delete target file.
@@
-73,25
+71,24
@@
error_code FileOutputBuffer::create(StringRef FilePath,
if (EC)
return EC;
if (EC)
return EC;
-
std::unique_ptr<mapped_file_region> MappedFile(new mapped_file_region
(
- FD, true, mapped_file_region::readwrite, Size, 0, EC)
)
;
+
auto MappedFile = llvm::make_unique<mapped_file_region>
(
+ FD, true, mapped_file_region::readwrite, Size, 0, EC);
if (EC)
return EC;
if (EC)
return EC;
- Result.reset(new FileOutputBuffer(MappedFile.get(), FilePath, TempFilePath));
- if (Result)
- MappedFile.release();
+ Result.reset(
+ new FileOutputBuffer(std::move(MappedFile), FilePath, TempFilePath));
- return error_code();
+ return
std::
error_code();
}
}
-error_code FileOutputBuffer::commit(int64_t NewSmallerSize) {
+
std::
error_code FileOutputBuffer::commit(int64_t NewSmallerSize) {
// Unmap buffer, letting OS flush dirty pages to file on disk.
// Unmap buffer, letting OS flush dirty pages to file on disk.
- Region.reset(
nullptr
);
+ Region.reset();
// If requested, resize file as part of commit.
if ( NewSmallerSize != -1 ) {
// If requested, resize file as part of commit.
if ( NewSmallerSize != -1 ) {
- error_code EC = sys::fs::resize_file(Twine(TempPath), NewSmallerSize);
+
std::
error_code EC = sys::fs::resize_file(Twine(TempPath), NewSmallerSize);
if (EC)
return EC;
}
if (EC)
return EC;
}