llvm.org GIT mirror llvm / 98f518c
unique_ptrify FileOutputBuffer::FileOutputBuffer git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216921 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 5 years ago
2 changed file(s) with 8 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
7676 FileOutputBuffer(const FileOutputBuffer &) LLVM_DELETED_FUNCTION;
7777 FileOutputBuffer &operator=(const FileOutputBuffer &) LLVM_DELETED_FUNCTION;
7878
79 FileOutputBuffer(llvm::sys::fs::mapped_file_region *R,
79 FileOutputBuffer(std::unique_ptr R,
8080 StringRef Path, StringRef TempPath);
8181
8282 std::unique_ptr Region;
1313 #include "llvm/Support/Errc.h"
1414 #include "llvm/Support/FileOutputBuffer.h"
1515 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/ADT/STLExtras.h"
1617 #include "llvm/Support/raw_ostream.h"
1718 #include
1819
1920 using llvm::sys::fs::mapped_file_region;
2021
2122 namespace llvm {
22 FileOutputBuffer::FileOutputBuffer(mapped_file_region * R,
23 FileOutputBuffer::FileOutputBuffer(std::unique_ptr R,
2324 StringRef Path, StringRef TmpPath)
24 : Region(R)
25 , FinalPath(Path)
26 , TempPath(TmpPath) {
27 }
25 : Region(std::move(R)), FinalPath(Path), TempPath(TmpPath) {}
2826
2927 FileOutputBuffer::~FileOutputBuffer() {
3028 sys::fs::remove(Twine(TempPath));
7270 if (EC)
7371 return EC;
7472
75 std::unique_ptr MappedFile(new mapped_file_region(
76 FD, true, mapped_file_region::readwrite, Size, 0, EC));
73 auto MappedFile = llvm::make_unique(
74 FD, true, mapped_file_region::readwrite, Size, 0, EC);
7775 if (EC)
7876 return EC;
7977
80 Result.reset(new FileOutputBuffer(MappedFile.get(), FilePath, TempFilePath));
81 if (Result)
82 MappedFile.release();
78 Result.reset(
79 new FileOutputBuffer(std::move(MappedFile), FilePath, TempFilePath));
8380
8481 return std::error_code();
8582 }