LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 35415 - 'clang-diagnostic-' checks not considered as enabled
Summary: 'clang-diagnostic-' checks not considered as enabled
Status: NEW
Alias: None
Product: clang-tools-extra
Classification: Unclassified
Component: clang-tidy (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-24 14:51 PST by Michał Kaptur
Modified: 2017-12-20 07:56 PST (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments
sample project to recreate the undesired behavior (670 bytes, application/gzip)
2017-11-24 14:51 PST, Michał Kaptur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Kaptur 2017-11-24 14:51:57 PST
Created attachment 19470 [details]
sample project to recreate the undesired behavior

'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.
Comment 1 David Wagner 2017-12-20 07:56:01 PST
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.

#34930 seems related.