6

I am using clang-tidy to lint my code base, but the entire process is very slow. Is there a way to completely ignore header files and not only suppress the warnings? As you can see with this example, a ton of warnings are coming from my project dependencies:

Suppressed 72958 warnings (72958 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
  • 1
    How are you currently invoking clang-tidy? – irowe May 03 '23 at 15:12
  • loosely related: [Ignore system headers in clang-tidy](/q/46638293/11107541), [clang-tidy - ignore third party headers code](/q/61101056/11107541), [Is it possible to ignore a header with clang-tidy](/q/71797349/11107541), [How to use SYSTEM headers with CMake and clang-tidy?](/q/61196994/11107541) – starball May 04 '23 at 04:38

2 Answers2

0

I don't think there's a good way to avoid processing the headers at all, since clang-tidy needs to build the abstract syntax tree in order to run the static analyzer checks. That's just how LLVM's LibTooling (what clang-tidy is built with) works. See this answer as well.

If speed is the problem (and you have multiple processor cores at your disposal), you can use run-clang-tidy.py, which runs checks for each file in your compilation database in parallel.

irowe
  • 638
  • 11
  • 21
0

Yes, you can ignore header files completely with clang-tidy by using the -header-filter option. The -header-filter option can be used to exclude headers from being checked by specifying a regular expression to match against header file names.

For example, to ignore all headers in your project's dependencies, you can use the following command:

clang-tidy -header-filter='^/path/to/your/project' /path/to/your/project/src/**/*.cpp

This command will only check the .cpp files in your project's src directory and its subdirectories, and will ignore all headers in the /path/to/your/project directory.

moinmaroofi
  • 359
  • 1
  • 12