<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55616>55616</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy fix for check cppcoreguidelines-prefer-member-initializer.UseAssignment doesn't work and initialization doesn't occur at the declaration
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
sean-mcmanus
</td>
</tr>
</table>
<pre>
Use clang-tidy 14.0.3.
Use code
```cpp
class C {
int n;
public:
C() {
n = 1;
}
};
```
Use command `clang-tidy.exe --config="{ Checks: 'cppcoreguidelines-prefer-member-initializer', CheckOptions: [{key: cppcoreguidelines-prefer-member-initializer.UseAssignment, value: true}]}" --fix <path>/test.cpp -- -std=c++17`.
Bug: The result is
```cpp
class C {
int n;
public:
C() : n(1) {
}
};
```
instead of something like
```cpp
class C {
int n = 1;
public:
C() : {
}
};
```
See the documentation at https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.html . Maybe the docs should be clarified if there is some reason for the difference.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VMlu2zAQ_RrqMrAgUZKXgw6x3dyKHtp-ACWOJNYUaZBUGvfrO5QcJ22AAg5QgOA225uZRzZWXurvHqHVwvSroOQF8jLN0iJl2ZFlD8s8a1iJ17t1toz2fF5uyNp7OADb7JcLAGUCGFZcz-ep0aplxcOL-MD4lvHdWwsAA6w4Qn6zAhIfrzFp83J9i_8e4jgKIyFCu-WT4jPCatVa06me_DPOKSgcBmxPnhAB4xtKpLUO-0lJ1MqgX50dduhWI44NLcqooIRWv9CRNuOHxfzLOShrFifVnrye8BIPd7hLCfeD96o3I5oQPT8JPWH0EhytlHZ1jDPnlESnnqlEh7MIAys-Mf4Y0IeUwpEMVj5Iyq9lfE8j31AV_mjifuqj228DgkM_6QDK_4eGUghD-_xdd-_pqTI-oJBgO_B2xDAo04NWp7sZ-Bej_gn7w2iX-SsiBCqutO0UmykiOUAEGEI4R5JQv2g41Cg8-lTrpzG1rqe7-cllsZ_Wak_rTN83Z3wOTtBKvm_imd3xsDCZNnfQbgijhhQ-i0tzQ-3BD3bSEpr5P3CqUyhBdVHukNgy94LIIzwl1lm3GKqOYqBp8cq2RNaF3BU7kQQVNNZvvpbI32g3Q_74MyGw6IlkmwA_rTtBfPM35aXsrxq2bScX2zCDxZjYrJJMTtd_tqZXYZialL4ROsT2XBfCZX9gS8_zUXk_YSx2Va3zdTLUTVluq6pr2m0p8q7biSzfyHInEEVRldUu0aJB7ev4QVTHRNU84zyreJZvi21ZpbIpchS82chtLrP1mpUZjkLpGz0SV88Ymqn3JNTKh1fuJGIuCuKLfzGFwbraozCrsaXfcPLJjLmeAf8GgDvJ0Q">