Search code examples
cmakestatic-analysisclang-tidyclang-static-analyzer

Ignore certain files when using clang-tidy


I'm trying to integrate clang-tidy with cmake, but there are some files that belong to a particular target which I would like to ignore.

Is there any way to make clang-tidy to ignore files under certain directory or whose name matches a certain pattern?


Solution

  • In the directory you want to ignore, create a .clang-tidy config file, that disables all checks with:

    Checks: '-*'
    

    If there is no way of keeping such a file in a repository, the file can be easily generated before running clang-tidy with echo "Checks: '-*'" > $folder2ignore/.clang-tidy. (This will even overwrite existing .clang-tidy, effectively disabling clang-tidy for the folder)