[llvm] r264314 - [docs] Clarify Error example in Programmer's Manual.

Rafael Espíndola via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 11:37:32 PDT 2016


So, what I meant in the other "example review" is that while I
personally like using auto in here, it seems in conflict with the
current rule:

----------------------------------------------------------------------------
Don’t “almost always” use auto, but do use auto with initializers
likecast<Foo>(...) or other places where the type is already obvious
from the context. Another time when auto works well for these purposes
is when the type would have been abstracted away anyways, often behind
a container’s typedef such asstd::vector<T>::iterator.
-------------------------------------------------------------------

Cheers,
Rafael


On 24 March 2016 at 14:05, Lang Hames via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: lhames
> Date: Thu Mar 24 13:05:21 2016
> New Revision: 264314
>
> URL: http://llvm.org/viewvc/llvm-project?rev=264314&view=rev
> Log:
> [docs] Clarify Error example in Programmer's Manual.
>
> Modified:
>     llvm/trunk/docs/ProgrammersManual.rst
>
> Modified: llvm/trunk/docs/ProgrammersManual.rst
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=264314&r1=264313&r2=264314&view=diff
> ==============================================================================
> --- llvm/trunk/docs/ProgrammersManual.rst (original)
> +++ llvm/trunk/docs/ProgrammersManual.rst Thu Mar 24 13:05:21 2016
> @@ -361,11 +361,13 @@ success, enabling the following idiom:
>
>  .. code-block:: c++
>
> -  if (auto Err = mayFail())
> -    return Err;
> -
> -  // Success! We can proceed.
> +  Error mayFail();
>
> +  Error foo() {
> +    if (auto Err = mayFail())
> +      return Err;
> +    // Success! We can proceed.
> +    ...
>
>  For functions that can fail but need to return a value the ``Expected<T>``
>  utility can be used. Values of this type can be constructed with either a
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list