[llvm] r216921 - unique_ptrify FileOutputBuffer::FileOutputBuffer
David Blaikie
dblaikie at gmail.com
Tue Sep 2 10:49:23 PDT 2014
Author: dblaikie
Date: Tue Sep 2 12:49:23 2014
New Revision: 216921
URL: http://llvm.org/viewvc/llvm-project?rev=216921&view=rev
Log:
unique_ptrify FileOutputBuffer::FileOutputBuffer
Modified:
llvm/trunk/include/llvm/Support/FileOutputBuffer.h
llvm/trunk/lib/Support/FileOutputBuffer.cpp
Modified: llvm/trunk/include/llvm/Support/FileOutputBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileOutputBuffer.h?rev=216921&r1=216920&r2=216921&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FileOutputBuffer.h (original)
+++ llvm/trunk/include/llvm/Support/FileOutputBuffer.h Tue Sep 2 12:49:23 2014
@@ -77,7 +77,7 @@ private:
FileOutputBuffer(const FileOutputBuffer &) LLVM_DELETED_FUNCTION;
FileOutputBuffer &operator=(const FileOutputBuffer &) LLVM_DELETED_FUNCTION;
- FileOutputBuffer(llvm::sys::fs::mapped_file_region *R,
+ FileOutputBuffer(std::unique_ptr<llvm::sys::fs::mapped_file_region> R,
StringRef Path, StringRef TempPath);
std::unique_ptr<llvm::sys::fs::mapped_file_region> Region;
Modified: llvm/trunk/lib/Support/FileOutputBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FileOutputBuffer.cpp?rev=216921&r1=216920&r2=216921&view=diff
==============================================================================
--- llvm/trunk/lib/Support/FileOutputBuffer.cpp (original)
+++ llvm/trunk/lib/Support/FileOutputBuffer.cpp Tue Sep 2 12:49:23 2014
@@ -14,18 +14,16 @@
#include "llvm/Support/Errc.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;
namespace llvm {
-FileOutputBuffer::FileOutputBuffer(mapped_file_region * R,
+FileOutputBuffer::FileOutputBuffer(std::unique_ptr<mapped_file_region> R,
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));
@@ -73,14 +71,13 @@ FileOutputBuffer::create(StringRef FileP
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;
- Result.reset(new FileOutputBuffer(MappedFile.get(), FilePath, TempFilePath));
- if (Result)
- MappedFile.release();
+ Result.reset(
+ new FileOutputBuffer(std::move(MappedFile), FilePath, TempFilePath));
return std::error_code();
}
More information about the llvm-commits
mailing list