[PATCH] D25316: [clang-tidy] Enhance modernize-use-auto to casts

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 31 11:56:22 PDT 2016


On Mon, Oct 31, 2016 at 2:55 PM, Malcolm Parsons
<malcolm.parsons at gmail.com> wrote:
> malcolm.parsons added inline comments.
>
>
> ================
> Comment at: clang-tidy/modernize/UseAutoCheck.cpp:404
> +                [](const Expr *Expr) { return Expr->getType(); },
> +                "use auto when initializing with new to avoid "
> +                "duplicating the type name");
> ----------------
> aaron.ballman wrote:
>> malcolm.parsons wrote:
>> > aaron.ballman wrote:
>> > > Quote use of `auto` and `new` in the diagnostic since they're syntax rather than english.
>> > A lot of clang-tidy diagnostics don't quote syntax/functions/types:
>> >
>> > ```
>> > "do not use reinterpret_cast"
>> > "pass by value and use std::move"
>> > "use nullptr"
>> > "the shrink_to_fit method should be used "
>> > "use std::move to transfer ownership"
>> > "auto_ptr is deprecated, use unique_ptr instead"
>> > "use auto when declaring iterators"
>> > "use range-based for loop instead"
>> > "use emplace_back instead of push_back"
>> > "prefer a lambda to std::bind"
>> > ...
>> > ```
>> clang-tidy hasn't always done a good job of following the conventions that clang uses for its diagnostics, but the reason I pointed this wording out specifically is because things like "new" are a valid word to use in an English sentence too, which makes the diagnostic text harder to understand without the quotes.
> The diagnostic with 'new' isn't new.

Correct, but you are adding a new instance of it, which is a good time
to fix things up.

> Let's cleanup the diagnostics in another patch.

I'm fine with that.

~Aaron


More information about the cfe-commits mailing list