brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 4661d2c Raw
67 lines · plain
1.. title:: clang-tidy - readability-inconsistent-declaration-parameter-name2 3readability-inconsistent-declaration-parameter-name4===================================================5 6Find function declarations which differ in parameter names.7 8Example:9 10.. code-block:: c++11 12  // in foo.hpp:13  void foo(int a, int b, int c);14 15  // in foo.cpp:16  void foo(int d, int e, int f); // warning17 18This check should help to enforce consistency in large projects, where it often19happens that a definition of function is refactored, changing the parameter20names, but its declaration in header file is not updated. With this check, we21can easily find and correct such inconsistencies, keeping declaration and22definition always in sync.23 24Unnamed parameters are allowed and are not taken into account when comparing25function declarations, for example:26 27.. code-block:: c++28 29  void foo(int a);30  void foo(int); // no warning31 32One name is also allowed to be a case-insensitive prefix/suffix of the other:33 34.. code-block:: c++35 36  void foo(int count);37  void foo(int count_input) { // no warning38    int count = adjustCount(count_input);39  }40 41To help with refactoring, in some cases fix-it hints are generated to align42parameter names to a single naming convention. This works with the assumption43that the function definition is the most up-to-date version, as it directly44references parameter names in its body. Example:45 46.. code-block:: c++47 48  void foo(int a); // warning and fix-it hint (replace "a" to "b")49  int foo(int b) { return b + 2; } // definition with use of "b"50 51In the case of multiple redeclarations or function template specializations,52a warning is issued for every redeclaration or specialization inconsistent with53the definition or the first declaration seen in a translation unit.54 55Options56-------57 58.. option:: IgnoreMacros59 60   If this option is set to `true` (default is `true`), the check will not warn61   about names declared inside macros.62 63.. option:: Strict64 65   If this option is set to `true` (default is `false`), then names must match66   exactly (or be absent).67