<div dir="ltr">Oh, of course - thanks for the explanation!</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 26, 2016 at 2:40 PM, Lang Hames <span dir="ltr"><<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Dave,<div><br></div><div>It's necessary I'm afraid. llvm::make_unique is operating under the same constraint as make_error: ECError's from-std::error_code constructor is now private. I've left the copy-constructor public though, so this works as is. Since ECError is a very simple class (just contains a std::error_code) I expect it should optimize away.</div><div><br></div><div>An alternative would be to make this:</div><div><br></div><div><font face="monospace, monospace">  return Error(std::unique_ptr<ECError>(new ECError(EC)));</font></div><div><br></div><div>But that doesn't remove the redundant reference to ECError.</div><div><br></div><div>Cheers,</div><div>Lang.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 26, 2016 at 2:24 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, May 26, 2016 at 2:15 PM, Lang Hames via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: lhames<br>
Date: Thu May 26 16:15:58 2016<br>
New Revision: 270916<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=270916&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=270916&view=rev</a><br>
Log:<br>
[Error] Make ECError only constructible via errorCodeToError.<br>
<br>
This enforces idiomatic usage of ECError removing the option to construct them<br>
using make_error.<br>
<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/Support/Error.h<br>
<br>
Modified: llvm/trunk/include/llvm/Support/Error.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Error.h?rev=270916&r1=270915&r2=270916&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Error.h?rev=270916&r1=270915&r2=270916&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Support/Error.h (original)<br>
+++ llvm/trunk/include/llvm/Support/Error.h Thu May 26 16:15:58 2016<br>
@@ -835,9 +835,8 @@ private:<br>
 /// (or Expected) and you want to call code that still returns<br>
 /// std::error_codes.<br>
 class ECError : public ErrorInfo<ECError> {<br>
+  friend Error errorCodeToError(std::error_code);<br>
 public:<br>
-  ECError() = default;<br>
-  ECError(std::error_code EC) : EC(EC) {}<br>
   void setErrorCode(std::error_code EC) { this->EC = EC; }<br>
   std::error_code convertToErrorCode() const override { return EC; }<br>
   void log(raw_ostream &OS) const override { OS << EC.message(); }<br>
@@ -846,6 +845,8 @@ public:<br>
   static char ID;<br>
<br>
 protected:<br>
+  ECError() = default;<br>
+  ECError(std::error_code EC) : EC(EC) {}<br>
   std::error_code EC;<br>
 };<br>
<br>
@@ -853,7 +854,7 @@ protected:<br>
 inline Error errorCodeToError(std::error_code EC) {<br>
   if (!EC)<br>
     return Error::success();<br>
-  return make_error<ECError>(EC);<br>
+  return Error(llvm::make_unique<ECError>(ECError(EC)));<br></blockquote><div><br></div></div></div><div>Do you have an extra "ECError" in there? Looks like it should be:<br><br>  return Error(llvm::make_unique<ECError>(EC));<br><br>?</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 }<br>
<br>
 /// Helper for converting an ECError to a std::error_code.<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>