[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 8 05:48:16 PST 2020


JonasToth added a comment.

In D72217#1809721 <https://reviews.llvm.org/D72217#1809721>, @njames93 wrote:

> In D72217#1809685 <https://reviews.llvm.org/D72217#1809685>, @njames93 wrote:
>
> > In D72217#1809212 <https://reviews.llvm.org/D72217#1809212>, @Eugene.Zelenko wrote:
> >
> > > By the word, will be interesting to see results of this check run on LLVM code. Probably results should be split on modules.
> >
> >
> > So ran it on clang and clang-tidy just crashed, gonna debug it see whats happening
>
>
> Crash fixed heres what happened when I ran it on clang/lib
>
> Quite a few occurances of const auto Decl which are renamed as const auto* const, or worse still a few that are redeclared as auto *const
>
>   /home/nathan/src/llvm-project/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp:623:3: warning: 'const auto IC' can be declared as 'const auto *const IC' [readability-qualified-auto]
>     const auto IC = dyn_cast<CXXInstanceCall>(&Call);
>     ^~~~~~~~~~~
>     const auto *const 
>   /home/nathan/src/llvm-project/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp:636:3: warning: 'const auto MethodDecl' can be declared as 'const auto *const MethodDecl' [readability-qualified-auto]
>     const auto MethodDecl = dyn_cast_or_null<CXXMethodDecl>(IC->getDecl());
>     ^~~~~~~~~~~
>     const auto *const 
>
>
> 286 files changed, without looking at header files. One file failed to build which is due to a dependant template. My guess is one call will have returned a naked pointer, and another returned an iterator, maybe I should disregard dependant templates unless it would be possible to deduce its always a pointer


Yes, templates are usually not so nice to handle well :/
One unfortunate thing I am currently looking for is checking if `auto->deducedType()` is a `tempateTypeParmType` or `substTemplateTypeParmType` through matchers, I failed. But in a sense you need to check for that condition for the cases `auto` -> direct; `auto &` -> pointee; `auto *` -> pointee.
>From my experience it helps to run it over `llvm/lib`, too as there is a lot of interesting c++ code in their. My checks broke there more often.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72217/new/

https://reviews.llvm.org/D72217





More information about the cfe-commits mailing list