<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55553>55553</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
readability-simplify-boolean-expr doesn't handle if condition variables or init statements
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
njames93
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
njames93
</td>
</tr>
</table>
<pre>
The check doesn't handle condition variables or c++17 if init statements resulting in malformed code.
```cpp
if (bool X = Cond)
Result = true;
else
Result = false;
// Transformed to Result = X;
if (bool X = Cond)
return true;
return false;
// Transformed to return X;
if (RAII Object; Cond)
Result = true;
else
Result = false;
// Transformed to Result = Cond; -> Removing the RAII object instance
if (bool X = Cond; X)
Result = true;
else
Result = false;
// Transformed to Result = X;
if (bool X = Cond; X)
return true;
return false;
// Transformed to return X;
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVlM1u2zAMgJ9Gvgg2bPkn9sGHdFmBngYUPeQqS7StTpYMSQ6Wtx_jJEuxLkB7GIYJBGSRNPlJItVZeWxfRqBiBPGdSgveELYJdORGalRbI1VQ1tADd4p3Gjy1jgrCHlCyDVU9VUYF6gMPMIEJnjrwiw7KDGihE9e9dRNIDCUhIemOpFtSpWcR83zWUBwYirC6s1bTPSX5jn7B5IQ1Nw9Kn9fYqzW4BUj-cLOC9nDHt-cn21tnwh5R6Ivjxl8Ag337y_6X--cIHYTFmfd0F_1HSS7u9ymet09P9Fv3CiKgz789qzU5QsQk_4r6yR5Otx-wrFZKu1JiNWCRGAEfO1UMt_8PLv8PmH-tAq5dE8k2l03e8CiooKF1wCXvlFbhGHs1zVr1x_gECtzE8GN27_saN3OntX_r5mhxuh1DmD3Jt2fQQYVx6RJhJ1xofbhO8ezsWo7sUXm_gMePEkceja0oIa-7uuFCVKLoBPAsT3tRp7Uoe1GkkeYdXmFLSnxXmNDcDHFQ8ogLUu4i1bKUsbTM6gznrEogK6p-U1Sc9anMmoIUKUxc6eQEklg3RK5dmbpl8GjUygd_M3Lv1WAALvnMK5_AN_klG1_CaF171Ubrbtp1Kz8BLT2HmQ">