Open llvmbot opened 7 years ago
I can confirm this with clang-tidy-5.0.1. It generates false negatives on files that will not compile:
I compile my code with GCC and do static analysis with clang-tidy. Because of varying implementation, GCC may accept code that clang doesn't. In such a case, clang-tidy will print something like:
file:line:col: error: ... [clang-diagnostic-error]
clang-tidy will then fail to analyse the file but will return a success code.
i checked this on git version
./clang-tidy --version
LLVM (http://llvm.org/):
LLVM version 19.0.0git
Optimized build with assertions.
I see that it does not list clang-diagnostic-*
in the checks
./clang-tidy --list-checks --checks='clang-diagnostic-*'
Enabled checks:
llvm-else-after-return
llvm-header-guard
llvm-include-order
llvm-namespace-comment
llvm-prefer-isa-or-dyn-cast-in-conditionals
llvm-prefer-register-over-unsigned
llvm-qualified-auto
llvm-twine-local
misc-confusable-identifiers
misc-coroutine-hostile-raii
misc-definitions-in-headers
misc-header-include-cycle
misc-misleading-bidirectional
misc-misleading-identifier
misc-misplaced-const
misc-new-delete-overloads
misc-non-copyable-objects
misc-redundant-expression
misc-static-assert
misc-throw-by-value-catch-by-reference
misc-unconventional-assign-operator
misc-uniqueptr-reset-release
misc-unused-alias-decls
misc-unused-using-decls
misc-use-internal-linkage
readability-identifier-naming
The clang-analyzer-*
checks are created programmatically in ClangTidy.cpp
using clang/lib/StaticAnalyzer/Checkers /*
/clang-tidy --list-checks --checks='clang-analyzer-*'
Enabled checks:
clang-analyzer-apiModeling.Errno
clang-analyzer-apiModeling.TrustNonnull
clang-analyzer-apiModeling.TrustReturnsNonnull
clang-analyzer-apiModeling.google.GTest
clang-analyzer-apiModeling.llvm.CastValue
clang-analyzer-apiModeling.llvm.ReturnValue
clang-analyzer-core.BitwiseShift
clang-analyzer-core.CallAndMessage
clang-analyzer-core.CallAndMessageModeling
clang-analyzer-core.DivideZero
clang-analyzer-core.DynamicTypePropagation
clang-analyzer-core.NonNullParamChecker
clang-analyzer-core.NonnilStringConstants
clang-analyzer-core.NullDereference
clang-analyzer-core.StackAddrEscapeBase
clang-analyzer-core.StackAddressEscape
....
Is there a way to obtain clang-diagnostic-*
in a similar way?. cc @llvm/pr-subscribers-clang-tidy
No, clang-diagnostic is just an proxy to compiler warnings, those are not a checks but a way to present compiler warnings.
Extended Description
'clang-diagnostic-' checks family cannot be the only one enabled for running clang-tidy due to 'no checks enabled' error: $ clang-tidy -checks='-*,clang-diagnostic-unused-variable' main.cpp Error: no checks enabled.
Extending check list by any other works fine for 'clang-diagnostic-' also: $ clang-tidy -checks='-*,cert-err34-c,clang-diagnostic-unused-variable' main.cpp 1 error generated.
What's worse, 'clang-diagnostic-' checks are not printed by listing all available checks: $ clang-tidy -checks='*' -list-checks | grep clang-diagnostic | wc -l 0
This is really counter-intuitive and makes the user doubt, whether 'clang-diagnostic' checks does still exist.
I've tested that on clang-tidy-5.0. There is a sample project attached to easily recreate the issue, with clang-tidy calls prepared.