Debian Codegraph @

clang-tools-extra/docs/clang-tidy/checks/readability/redundant-declaration.rst

raw
1 .. title:: clang-tidy - readability-redundant-declaration
2
3 readability-redundant-declaration
4 =================================
5
6 Finds redundant variable and function declarations.
7
8 .. code-block:: c++
9
10 extern int X;
11 extern int X;
12
13 becomes
14
15 .. code-block:: c++
16
17 extern int X;
18
19 Such redundant declarations can be removed without changing program behavior.
20 They can for instance be unintentional left overs from previous refactorings
21 when code has been moved around. Having redundant declarations could in worst
22 case mean that there are typos in the code that cause bugs.
23
24 Normally the code can be automatically fixed, :program:`clang-tidy` can remove
25 the second declaration. However there are 2 cases when you need to fix the code
26 manually:
27
28 * When the declarations are in different header files;
29 * When multiple variables are declared together.
30
31 Options
32 -------
33
34 .. option:: IgnoreMacros
35
36 If set to `true`, the check will not give warnings inside macros. Default
37 is `true`.