brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 3d90245 Raw
48 lines · plain
1.. title:: clang-tidy - misc-unused-parameters2 3misc-unused-parameters4======================5 6Finds unused function parameters. Unused parameters may signify a bug in the7code (e.g. when a different parameter is used instead). The suggested fixes8either comment parameter name out or remove the parameter completely, if all9callers of the function are in the same translation unit and can be updated.10 11The check is similar to the `-Wunused-parameter` compiler diagnostic and12can be used to prepare a codebase to enabling of that diagnostic. By default13the check 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  // becomes20 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  // becomes29 30  static void staticFunctionA()31  static void staticFunctionA() { /*some code that doesn't use `i`*/ }32 33Options34-------35 36.. option:: StrictMode37 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 of40  constructors - no constructor initializers). When the function body is empty,41  an unused parameter is unlikely to be unnoticed by a human reader, and42  there's basically no place for a bug to hide.43 44.. option:: IgnoreVirtual45 46  Determines whether virtual method parameters should be inspected.47  Set to `true` to ignore them. Default is `false`.48