Debian Codegraph @

clang-tools-extra/docs/clang-tidy/checks/misc/unused-parameters.rst

raw
1 .. title:: clang-tidy - misc-unused-parameters
2
3 misc-unused-parameters
4 ======================
5
6 Finds unused function parameters. Unused parameters may signify a bug in the
7 code (e.g. when a different parameter is used instead). The suggested fixes
8 either comment parameter name out or remove the parameter completely, if all
9 callers of the function are in the same translation unit and can be updated.
10
11 The check is similar to the ``-Wunused-parameter`` compiler diagnostic and can be
12 used to prepare a codebase to enabling of that diagnostic. By default the check
13 is more permissive (see :option:`StrictMode`).
14
15 .. code-block:: c++
16
17 void a(int i) { /*some code that doesn't use `i`*/ }
18
19 // becomes
20
21 void a(int /*i*/) { /*some code that doesn't use `i`*/ }
22
23 .. code-block:: c++
24
25 static void staticFunctionA(int i);
26 static void staticFunctionA(int i) { /*some code that doesn't use `i`*/ }
27
28 // becomes
29
30 static void staticFunctionA()
31 static void staticFunctionA() { /*some code that doesn't use `i`*/ }
32
33 Options
34 -------
35
36 .. option:: StrictMode
37
38 When `false` (default value), the check will ignore trivially unused parameters,
39 i.e. when the corresponding function has an empty body (and in case of
40 constructors - no constructor initializers). When the function body is empty,
41 an unused parameter is unlikely to be unnoticed by a human reader, and
42 there's basically no place for a bug to hide.
43
44 .. option:: IgnoreVirtual
45
46 Determines whether virtual method parameters should be inspected.
47 Set to `true` to ignore them. Default is `false`.