[PATCH] D28010: FileOutputBuffer: support non-mmap'able file.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 21 01:23:52 PST 2016


ruiu added inline comments.


================
Comment at: llvm/lib/Support/FileOutputBuffer.cpp:159
+  if (fs::is_other(Stat))
+    return std::unique_ptr<FileOutputBuffer>(
+        new FileOutputBuffer(Path, Size, new NonMMappedFile(Path, Size)));
----------------
grimar wrote:
> ruiu wrote:
> > grimar wrote:
> > > llvm::make_unique may be ?
> > Why?
> That should be shorter and avoids using "new".
> 
> It is generally also consistent with recomendations to use std::make_shared instead of std::shared_ptr(new X) which is preffered because of different reasons usually (single allocation of T and control block in most of implementations for example).
Ah, there's a reason why we can't use make_unique. The FileOutputBuffer ctor is private, so we need to instantiate it from this function. This function is a member of that class, so it can call the ctor. However, make_unique is not, so it can't.


https://reviews.llvm.org/D28010





More information about the llvm-commits mailing list