xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst (revision 724b40a1379f7c116473a02a3cec4d341c475b46)
1.. title:: clang-tidy - misc-include-cleaner
2
3misc-include-cleaner
4====================
5
6Checks for unused and missing includes. Generates findings only for
7the main file of a translation unit.
8Findings correspond to https://clangd.llvm.org/design/include-cleaner.
9
10Example:
11
12.. code-block:: c++
13
14   // foo.h
15   class Foo{};
16   // bar.h
17   #include "baz.h"
18   class Bar{};
19   // baz.h
20   class Baz{};
21   // main.cc
22   #include "bar.h" // OK: uses class Bar from bar.h
23   #include "foo.h" // warning: unused include "foo.h"
24   Bar bar;
25   Baz baz; // warning: missing include "baz.h"
26
27Options
28-------
29
30.. option:: IgnoreHeaders
31
32   A semicolon-separated list of regexes to disable insertion/removal of header
33   files that match this regex as a suffix.  E.g., `foo/.*` disables
34   insertion/removal for all headers under the directory `foo`. By default, no
35   headers will be ignored.
36
37.. option:: DeduplicateFindings
38
39   A boolean that controls whether the check should deduplicate findings for the
40   same symbol. Defaults to `true`.
41