[llvm-dev] returning Expected<tool_output_file>

Dvir Yitzchaki via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 11 05:31:18 PDT 2017

Hi list.

I've wrote a function which creates an output file as follows:

createOutputFile(llvm::StringRef FileName) {
  std::error_code EC;
  llvm::tool_output_file Out(FileName, EC, llvm::sys::fs::F_Text);
  if (EC) {
    return llvm::errorCodeToError(EC);

  return Out;

This fails to compile, however because tool_output_file is not copyable or even moveable which Expected requires.
If I add default move constructors to raw_ostream and raw_fd_ostream the code above compile fine.
Is such a patch welcome? Is there a different way to achieve this?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170711/6ae28161/attachment.html>

More information about the llvm-dev mailing list