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

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 8 02:47:54 PST 2020


njames93 added a comment.

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

  /home/nathan/src/llvm-project/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp:365:9: error: variable 'It' with type 'auto *' has incompatible initializer of type 'typename std::conditional<std::is_const<vector<CheckerInfo, allocator<CheckerInfo> > >::value, typename vector<CheckerInfo, allocator<CheckerInfo> >::const_iterator, typename vector<CheckerInfo, allocator<CheckerInfo> >::iterator>::type' (aka '__gnu_cxx::__normal_iterator<clang::ento::CheckerRegistry::CheckerInfo *, std::vector<clang::ento::CheckerRegistry::CheckerInfo, std::allocator<clang::ento::CheckerRegistry::CheckerInfo> > >')
    auto *It = binaryFind(Collection, FullName);
          ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /home/nathan/src/llvm-project/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp:378:5: note: in instantiation of function template specialization 'insertOptionToCollection<std::vector<clang::ento::CheckerRegistry::CheckerInfo, std::allocator<clang::ento::CheckerRegistry::CheckerInfo> > >' requested here
      insertOptionToCollection(CheckerOptEntry.first, Checkers,
      ^
  1 error generated.


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

https://reviews.llvm.org/D72217





More information about the cfe-commits mailing list