Skip to content

clang-tidy fails with “Error: no checks enabled” on .clang-tidy file which --verify-config verifies #86355

@FlashSheridan

Description

@FlashSheridan

Steps to Reproduce:

With the attached .clang-tidy (a simplified version of our naïve attempt to disable all checkers in a subdirectory we didn’t own), try the following:

clang-tidy --verify-config simple.c 
clang-tidy simple.c

Expected Results

Preferably, the simple clang-tidy invocation would return success. Failing that, the --verify-config invocation should warn that the configuration was unacceptable.

Actual Results

clang-tidy --verify-config simple.c 
No config errors detected.


clang-tidy simple.c
Error: no checks enabled.
…
 
echo $?
1

Workaround

Enable an irrelevant checker; see the attached SuperCall.clang-tidy:

clang-tidy --config-file=SuperCall.clang-tidy simple.c

echo $?
0

Limitation

Explicitly disabling clang-diagnostic-error does not work. Uncomment the bogus inclusion in simple.c:

clang-tidy --config-file=Suppress_clang-diagnostic-error.clang-tidy simple.c
1 error generated.
Error while processing /Users/flash/Documents/Bugs/Bug_files/Tidy_Bugs/simple.c.
/Users/flash/Documents/Bugs/Bug_files/Tidy_Bugs/simple.c:1:10: error: 'WarpDarkMatter.h' file not found [clang-diagnostic-error]
    1 | #include "WarpDarkMatter.h"
      |          ^~~~~~~~~~~~~~~~~~
Found compiler error(s).


echo $?
1

This is a severe problem for us, since some parts of the CMake process for lld work fine for actually building our fork, but cause inclusion problems in unittests (which we don’t own) when running clang-tidy (which we’re still investigating).

Related:

Configuration

MacOS 13.6.5 22G621 on M1 Max
clang-tidy built in clang version 19.0.0git ([email protected]:llvm/llvm-project.git 6b1cf00
MacOSX14.2.sdk
Xcode 15.2 15C500b, Apple clang-1500.1.0.2.5

Files:

Files.zip

  • .clang-tidy:
---
Checks: >
        -clang-analyzer-apiModeling.Errno,
        -*,
  • simple.c
  • CMakeLists.txt:
  • compile_commands.json
  • SuperCall.clang-tidy
  • Suppress_clang-diagnostic-error.clang-tidy

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-tidyquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions