Skip to content

clang-tidy fails to parse config files silently, even with --verify-config. #77341

@knjmooney

Description

@knjmooney

If you have an invalid clang-tidy config file, clang-tidy carries on silently and uses the default configuration settings. I've encountered this in several projects where there is a typo in the clang-tidy config file, which results in the default config being used.

With verify-config, the errors are reported, but it eventually claims "No config error detected" and sets a successful exit code.

 -> clang-tidy-17 --version                                    
Ubuntu LLVM version 17.0.4
  Optimized build.

 -> echo "This is not a valid clang-tidy file" > .clang-tidy   
                                                                                                                                                                                                                                                                                                                              
 -> clang-tidy-17 --verify-config && echo PASSED || echo FAILED
/tmp/test/.clang-tidy:1:1: error: not a mapping
This is not a valid clang-tidy file
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error parsing /tmp/test/.clang-tidy: Invalid argument
/tmp/test/.clang-tidy:1:1: error: not a mapping
This is not a valid clang-tidy file
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error parsing /tmp/test/.clang-tidy: Invalid argument
No config errors detected.
PASSED

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions