From 98f518c81af3dedd1cdd02718f350322f47dc163 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 2 Sep 2014 17:49:23 +0000 Subject: [PATCH] unique_ptrify FileOutputBuffer::FileOutputBuffer git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216921 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/FileOutputBuffer.h | 2 +- lib/Support/FileOutputBuffer.cpp | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/llvm/Support/FileOutputBuffer.h b/include/llvm/Support/FileOutputBuffer.h index 0a9a9799515..a7cfacd191b 100644 --- a/include/llvm/Support/FileOutputBuffer.h +++ b/include/llvm/Support/FileOutputBuffer.h @@ -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 R, StringRef Path, StringRef TempPath); std::unique_ptr Region; diff --git a/lib/Support/FileOutputBuffer.cpp b/lib/Support/FileOutputBuffer.cpp index 94bcdc58a80..c62655d58d5 100644 --- a/lib/Support/FileOutputBuffer.cpp +++ b/lib/Support/FileOutputBuffer.cpp @@ -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 using llvm::sys::fs::mapped_file_region; namespace llvm { -FileOutputBuffer::FileOutputBuffer(mapped_file_region * R, +FileOutputBuffer::FileOutputBuffer(std::unique_ptr 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 FilePath, size_t Size, if (EC) return EC; - std::unique_ptr MappedFile(new mapped_file_region( - FD, true, mapped_file_region::readwrite, Size, 0, EC)); + auto MappedFile = llvm::make_unique( + 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(); } -- 2.34.1