[cfe-dev] [llvm-dev] RFC: Modernizing our use of auto

Piotr Padlewski via cfe-dev cfe-dev at lists.llvm.org
Thu Dec 6 02:12:51 PST 2018

I agree with George here, the current implementation of modernize-use-auto
<http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html> uses
pretty much the same rules as described in our coding standards which we
all agree on, mainly:
- iterators (begin, end)
- cast expressions
- new expression

Ofc there are more cases where type is obvious and where we would like to
use auto, but automating the part that modernize-use-auto can do is enough
to cover most of the cases.


czw., 6 gru 2018 o 08:46 George Burgess IV via cfe-dev <
cfe-dev at lists.llvm.org> napisał(a):

> So the problem becomes one of seeing if people will accept `auto` rules
> that don't require substantial amounts of thought.
> Personally, I see this like our use of clang-format. It might not use my
> favorite color of paint, but it's uniform, automatic, and it lets me
> entirely forget about tons of style nits, so I love it to death. Hence, if
> we need to start with "no auto, except in this small set of trivially OK
> and machine-verifiable cases, which we'll consider expanding this as need
> arises," to get to that, I'd be all for it.
> I realize that many devs probably strongly disagree with me here, but
> that's my 2c.
> On Wed, Dec 5, 2018 at 9:26 PM Chris Lattner <clattner at nondot.org> wrote:
>> > On Dec 4, 2018, at 10:59 AM, George Burgess IV <
>> george.burgess.iv at gmail.com> wrote:
>> >
>> > > I think people are too eager to use `auto` because it is easy to
>> write but it makes the types substantially harder for the reader to
>> understand
>> >
>> > I'm probably the Nth person to ask this, but what keeps us from
>> promoting the use of a clang-tidy-powered tool that basically emits fixits
>> of s/auto/actual_type/?
>> Because the tool would need to apply judgement to when this makes sense.
>> If we can’t write an algorithm in coding standards.html to be prescriptive
>> about when to use auto, then I don’t think we can automate this.
>> -Chris
>> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181206/51954a4d/attachment.html>

More information about the cfe-dev mailing list