xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/readability/duplicate-include.rst (revision 6e566bc5523f743bc34a7e26f050f1f2b4d699a8)
1.. title:: clang-tidy - readability-duplicate-include
2
3readability-duplicate-include
4=============================
5
6Looks for duplicate includes and removes them.  The check maintains a list of
7included files and looks for duplicates.  If a macro is defined or undefined
8then the list of included files is cleared.
9
10Examples:
11
12.. code-block:: c++
13
14  #include <memory>
15  #include <vector>
16  #include <memory>
17
18becomes
19
20.. code-block:: c++
21
22  #include <memory>
23  #include <vector>
24
25Because of the intervening macro definitions, this code remains unchanged:
26
27.. code-block:: c++
28
29  #undef NDEBUG
30  #include "assertion.h"
31  // ...code with assertions enabled
32
33  #define NDEBUG
34  #include "assertion.h"
35  // ...code with assertions disabled
36