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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 11:55:46 PDT 2016


On Thu, Mar 24, 2016 at 11:52 AM, Rafael Espíndola <
rafael.espindola at gmail.com> wrote:

> On 24 March 2016 at 14:46, David Blaikie <dblaikie at gmail.com> wrote:
> >
> >
> > On Thu, Mar 24, 2016 at 11:37 AM, Rafael Espíndola
> > <llvm-commits at lists.llvm.org> wrote:
> >>
> >> 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.
> >
> >
> > 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.
> >
> > 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.
> >
> > At least that's my guess/feeling.
>
> I agree that the type doesn't add much. How about explicitly saying
> that it is OK to use auto when just propagating errors?
>

I'm not sure it adds much to the style guide (I think it's a reasonable
interpretation that the type is obvious from context in this case) &
keeping the style guide short helps make it accessible/useful.

If something was added to the guide here I'd probably make it a bit more
broad "when the type information isn't useful" (eg: the type is just being
passed from one place to another/called with an obvious function, etc) auto
might be suitable.

eg: I can write "foo(bar())" without writing the type of the result of bar,
so just because I need to write "x = foo(); bar(x, x)" doesn't mean the
type of x is any more important.


>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160324/e2a81217/attachment.html>


More information about the llvm-commits mailing list