<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 24, 2016 at 11:37 AM, Rafael Espíndola <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">So, what I meant in the other "example review" is that while I<br>
personally like using auto in here, it seems in conflict with the<br>
current rule:<br>
<br>
----------------------------------------------------------------------------<br>
Don’t “almost always” use auto, but do use auto with initializers<br>
likecast<Foo>(...) or other places where the type is already obvious<br>
from the context.</blockquote><div><br></div><div>I'd say this fits the "already obvious from context" in this example - the return type is only a few lines away, the name indicates that it's an error result & the more details about the type aren't very helpful in this context "it's an error that's being propagated" - we don't need to know much more about it.<br><br>I don't think this use of auto should be seen as integral to the example - just appropriate in that context & the use of auto when passing around errors should be evaluated as usual in a case-by-case basis as per the style guide.<br><br>At least that's my guess/feeling.<br><br>- Dave</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Another time when auto works well for these purposes<br>
is when the type would have been abstracted away anyways, often behind<br>
a container’s typedef such asstd::vector<T>::iterator.<br>
-------------------------------------------------------------------<br>
<br>
Cheers,<br>
Rafael<br>
<br>
<br>
On 24 March 2016 at 14:05, Lang Hames via llvm-commits<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: lhames<br>
> Date: Thu Mar 24 13:05:21 2016<br>
> New Revision: 264314<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264314&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=264314&view=rev</a><br>
> Log:<br>
> [docs] Clarify Error example in Programmer's Manual.<br>
><br>
> Modified:<br>
>     llvm/trunk/docs/ProgrammersManual.rst<br>
><br>
> Modified: llvm/trunk/docs/ProgrammersManual.rst<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=264314&r1=264313&r2=264314&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=264314&r1=264313&r2=264314&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/docs/ProgrammersManual.rst (original)<br>
> +++ llvm/trunk/docs/ProgrammersManual.rst Thu Mar 24 13:05:21 2016<br>
> @@ -361,11 +361,13 @@ success, enabling the following idiom:<br>
><br>
>  .. code-block:: c++<br>
><br>
> -  if (auto Err = mayFail())<br>
> -    return Err;<br>
> -<br>
> -  // Success! We can proceed.<br>
> +  Error mayFail();<br>
><br>
> +  Error foo() {<br>
> +    if (auto Err = mayFail())<br>
> +      return Err;<br>
> +    // Success! We can proceed.<br>
> +    ...<br>
><br>
>  For functions that can fail but need to return a value the ``Expected<T>``<br>
>  utility can be used. Values of this type can be constructed with either a<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">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>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">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>
</div></div></blockquote></div><br></div></div>