196 lines · plain
1.. title:: clang-tidy - bugprone-argument-comment2 3bugprone-argument-comment4=========================5 6Checks that argument comments match parameter names.7 8The check understands argument comments in the form ``/*parameter_name=*/``9that are placed right before the argument.10 11.. code-block:: c++12 13 void f(bool foo);14 15 ...16 17 f(/*bar=*/true);18 // warning: argument name 'bar' in comment does not match parameter name 'foo'19 20The check tries to detect typos and suggest automated fixes for them.21 22Options23-------24 25.. option:: StrictMode26 27 When `false`, the check will ignore leading and trailing28 underscores and case when comparing names -- otherwise they are taken into29 account. Default is `false`.30 31.. option:: IgnoreSingleArgument32 33 When `true`, the check will ignore the single argument. Default is `false`.34 35.. option:: CommentBoolLiterals36 37 When `true`, the check will add argument comments in the format38 ``/*ParameterName=*/`` right before the boolean literal argument.39 Default is `false`.40 41Before:42 43.. code-block:: c++44 45 void foo(bool TurnKey, bool PressButton);46 47 foo(true, false);48 49After:50 51.. code-block:: c++52 53 void foo(bool TurnKey, bool PressButton);54 55 foo(/*TurnKey=*/true, /*PressButton=*/false);56 57.. option:: CommentIntegerLiterals58 59 When `true`, the check will add argument comments in the format60 ``/*ParameterName=*/`` right before the integer literal argument.61 Default is `false`.62 63Before:64 65.. code-block:: c++66 67 void foo(int MeaningOfLife);68 69 foo(42);70 71After:72 73.. code-block:: c++74 75 void foo(int MeaningOfLife);76 77 foo(/*MeaningOfLife=*/42);78 79.. option:: CommentFloatLiterals80 81 When `true`, the check will add argument comments in the format82 ``/*ParameterName=*/`` right before the float/double literal argument.83 Default is `false`.84 85Before:86 87.. code-block:: c++88 89 void foo(float Pi);90 91 foo(3.14159);92 93After:94 95.. code-block:: c++96 97 void foo(float Pi);98 99 foo(/*Pi=*/3.14159);100 101.. option:: CommentStringLiterals102 103 When `true`, the check will add argument comments in the format104 ``/*ParameterName=*/`` right before the string literal argument.105 Default is `false`.106 107Before:108 109.. code-block:: c++110 111 void foo(const char *String);112 void foo(const wchar_t *WideString);113 114 foo("Hello World");115 foo(L"Hello World");116 117After:118 119.. code-block:: c++120 121 void foo(const char *String);122 void foo(const wchar_t *WideString);123 124 foo(/*String=*/"Hello World");125 foo(/*WideString=*/L"Hello World");126 127.. option:: CommentCharacterLiterals128 129 When `true`, the check will add argument comments in the format130 ``/*ParameterName=*/`` right before the character literal argument.131 Default is `false`.132 133Before:134 135.. code-block:: c++136 137 void foo(char *Character);138 139 foo('A');140 141After:142 143.. code-block:: c++144 145 void foo(char *Character);146 147 foo(/*Character=*/'A');148 149.. option:: CommentUserDefinedLiterals150 151 When `true`, the check will add argument comments in the format152 ``/*ParameterName=*/`` right before the user defined literal argument.153 Default is `false`.154 155Before:156 157.. code-block:: c++158 159 void foo(double Distance);160 161 double operator"" _km(long double);162 163 foo(402.0_km);164 165After:166 167.. code-block:: c++168 169 void foo(double Distance);170 171 double operator"" _km(long double);172 173 foo(/*Distance=*/402.0_km);174 175.. option:: CommentNullPtrs176 177 When `true`, the check will add argument comments in the format178 ``/*ParameterName=*/`` right before the nullptr literal argument.179 Default is `false`.180 181Before:182 183.. code-block:: c++184 185 void foo(A* Value);186 187 foo(nullptr);188 189After:190 191.. code-block:: c++192 193 void foo(A* Value);194 195 foo(/*Value=*/nullptr);196