<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/93157>93157</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
confusing `readability-simplify-boolean-exp` warning with conditional code
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
firewave
</td>
</tr>
</table>
<pre>
```cpp
bool f(int i)
{
if (i == 0)
return false;
#ifdef STRICT
if (i < 0)
return false;
#endif
return true;
}
```
```
<source>:4:16: warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]
4 | return false;
| ^
```
https://godbolt.org/z/f9ePxjWrr
If you remove the preprocessor block the warning makes sense.
```
<source>:4:16: warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]
3 | if (i == 0)
| ~~~~~~~~~~~
| return i != 0
4 | return false;
| ~~~~~~~^~~~~~
5 |
6 | return true;
| ~~~~~~~~~~~
```
Although I think this should not be reported since it cannot be fixed because of the conditional block.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVM9v4ygU_mueL0-JCAQ7OfiQNo3U22p3pD2DecTMELAAt80e9m9fOXGnTVVt5zrIsp_h4_34-B4qZ3cMRC3IO5D7So2lj6m1LtGzeqJKR3NuoWbXpxsGYHtgOx2jRwt840JBB3x7nYbm7mogIjqLEwBB7EHskf1E4TwSlTEFtMpnAjHvnN9cOGvI4l_f_ny8__aZ0_tf9sgFBePsG3S2ZnRJ4ztws5-N15pv0vowKe5zHFNHIB5A7NYgdqsaxA6fVQouHCczkRmDUaHgxBmpgN4VSsqjC9jFYFxxMSj_mk0uqtCJQkGQd4mUUdp5V86L7E6Dd_a8mP0s6GVIIPdvZa0Rmnv8Xy5uEPMA-fBpdX0pQwaxA34AfjhGo6Mvy5iOwA__AD_YLf3x8v3vlN4z9GjxHEdMdIpPhKUnHBINKXaUc0yofex-XKZnivCkflDGTCHT8vehWlyI_ELhr1z_-zY-W56zcQh8dXVzBf3Kcd44ehcL5MOHePICm__rj8FveuCL7D_tjJ0vfRyPPT5i6V2YzthlzH0cvcEQC2rCRENMhQxmFzpCV7BTYV6z7oUMaurUmAmjvWjk_ZldlLOsTCvMVmxVRe2qWdVrKTdSVn3bbFitG6W4tmyjSSvJpTbdRlltzNqyyrWc8TWTXLDtqhFyyWpbK1PrrWWC1dLCmtFJOb_0_uk0ybxyOY_UbsVKNpVXmny-3JKcd16F46I4cwbOp1sztdOmhR6PGdbMu1zym5viiqe2i8GOeVI81OwrsUHNfjbIsyv9DRNdNFSNybcfGtSVftTLLp6AH6bg82cxpPidugL8cCkoAz9ca3pq-X8BAAD__57wxzY">