Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I enable clang-tidy's "modernize" checks?

I just installed ClangOnWin,and I'm trying to get clang-tidy's "modernize" checks to work. Unfortunately, clang-tidy doesn't seem to know about them: clang-tidy -list-checks foo.cpp -- | grep modernize produces no output.

The "modernize" checks are listed here, but that page seems to document Clang 3.8, and the version I have installed is 3.7. However, version 3.7 is the current one listed at the LLVM Download Page.

clang-tidy knows about a variety of security checks, so I think I have it installed correctly. For example, clang-tidy -list-checks foo.cpp -- | grep security yields this:

clang-analyzer-security.FloatLoopCounter
clang-analyzer-security.insecureAPI.UncheckedReturn
clang-analyzer-security.insecureAPI.getpw
clang-analyzer-security.insecureAPI.gets
clang-analyzer-security.insecureAPI.mkstemp
clang-analyzer-security.insecureAPI.mktemp
clang-analyzer-security.insecureAPI.rand
clang-analyzer-security.insecureAPI.strcpy
clang-analyzer-security.insecureAPI.vfork

Is there something special I need to do to enable checks such as modernize-use-override and modernize-use-nullptr?

like image 678
KnowItAllWannabe Avatar asked Nov 16 '15 19:11

KnowItAllWannabe


People also ask

What is clang tidy check?

clang-tidy is a clang-based C++ “linter” tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via static analysis.

What is clang tidy checks Android studio?

Clang-Tidy is a Clang-based tool for static code analysis. CLion shows Clang-Tidy checks the same way as its own code inspections, with quick-fixes available via the -button or Alt+Enter : Gif.


2 Answers

The modernize checks were added after 3.7 (ported from clang-modernize), but try adding -checks="*" to see the whole list of available checks.

clang-tidy -list-checks -checks="*" foo.cpp --
like image 173
holedigger Avatar answered Oct 20 '22 03:10

holedigger


Have you tried with the official binaries from LLVM: http://llvm.org/releases/download.html ? Maybe the ClangOnWin binaries are not compiled with all options, or something of that kind.

like image 31
Baptiste Wicht Avatar answered Oct 20 '22 04:10

Baptiste Wicht