[PATCH] D26884: Change setDiagnosticsOutputFile to take a unique_ptr from a raw pointer (NFC)

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 19 12:44:58 PST 2016


mehdi_amini added inline comments.


================
Comment at: llvm/include/llvm/IR/LLVMContext.h:197
   /// set, the handler is invoked for each diagnostic message.
-  void setDiagnosticsOutputFile(yaml::Output *F);
+  void setDiagnosticsOutputFile(std::unique_ptr<yaml::Output> F);
 
----------------
malcolm.parsons wrote:
> mehdi_amini wrote:
> > malcolm.parsons wrote:
> > > Pass by value if always moving doesn't apply to move-only types. Use && to avoid a temporary.
> > Sorry I don't understand this comment?
> Functions that accept a parameter by value do so to allow the caller to choose whether to supply an lvalue that is copied or an rvalue that is moved without having to write overloads for both.
> For a move-only type there is no choice, so the function should accept an rvalue.
> This might avoid the construction and destruction of a temporary.
I see. It does not really sound idiomatic to me to have any unique_ptr passed by rvalue, you should try to submit a patch to the developer guide.

(I'm not really convinced by the "avoid the construction and destruction of a temporary" here, I don't expect the codegen to be any different)


Repository:
  rL LLVM

https://reviews.llvm.org/D26884





More information about the llvm-commits mailing list