| Issue |
159251
|
| Summary |
[clang-tidy] `readability-implicit-bool-conversion` is too noisy by default
|
| Labels |
enhancement,
clang-tidy
|
| Assignees |
|
| Reporter |
firewave
|
Out-of-the-box the `readability-implicit-bool-conversion` is way too noisy to be usable.
`AllowIntegerConditions` and `AllowPointerConditions` should be set to `true` to be begin with as those are common patterns.
With those patterns allowed I would expect that I only get assignments where an implicit conversion is allowed (which might actually indicate an unintentional behavior so that pattern rather belongs into `misc-*` or `bugprone-*`). But usages in `return` statements will still produce warnings.
```cpp
bool f2(int i, int* i1, int& i2)
{
if (i) {
return i;
}
if (i1) {
return *i1;
}
return i2;
}
```
```
<source>:4:16: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
4 | return i;
| ^
| != 0
<source>:7:16: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
7 | return *i1;
| ^
| != 0
<source>:9:12: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
9 | return i2;
| ^
| != 0
```
https://godbolt.org/z/jnWjbea13
This is also a very common pattern but it is not a condition and more akin to an assignment. So maybe that case should get additional (off by default) options. This is already tracked in #79447.
It is possible that there are more cases but it is hard to tell with the amount of warnings the check currently produces. There is also more related issues:
#63450
#36323
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs