[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 28 03:46:36 PST 2020
njames93 added a comment.
In D72217#1844112 <https://reviews.llvm.org/D72217#1844112>, @sammccall wrote:
> This check as configured for LLVM itself is pretty noisy, generating warnings like:
>
> > warning: 'auto *CTSD' can be declared as 'const auto *CTSD' [llvm-qualified-auto]
>
> which the LLVM dev guide doesn't have an opinion about.
>
> AFAICS there's no option to disable just the const behavior, and no proposal to change the dev guidelines - is someone working on something here?
> Otherwise I'd like to turn this off at least for clang-tools-extra.
https://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto
// Copy pointers, but make it clear that they're pointers.
for (const auto *Ptr : Container) { observe(*Ptr); }
for (auto *Ptr : Container) { Ptr->change(); }
This is the reasoning behind putting the const qualifier in the check. If people feel that this isn't quite enough to justify the const qualifier I'll submit a follow up. The general consensus though is that you should mark auto pointers as const if they don't need to change to express intent
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72217/new/
https://reviews.llvm.org/D72217
More information about the cfe-commits
mailing list