Issue 111013
Summary [clang-tidy] readability-implicit-bool-conversion emits useless fixit for comparisons in C
Labels bug, clang-tidy
Assignees
Reporter 5chmidti
    In C, the result of a comparison is defined as returning a `1` or a `0` of type `int` (C N3220 6.5.9.7 & 6.5.10.4). 

https://godbolt.org/z/fTErfvzqW

```C++
bool foo() { return 1 != 0; }
```

```
[<source>:1:21: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]](_javascript_:;)
 1 | bool foo() { return 1 != 0; }
      |                     ^     
 |                     (     ) != 0
1 warning generated.
```

The check should probably be adapted to check if the source _expression_ of the cast is a comparison (ignoring parens), and just add a cast instead.

Additionally, a new option could be added to ignore the conversion warning in this case for C.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to