Issue 93157
Summary confusing `readability-simplify-boolean-exp` warning with conditional code
Labels clang-tidy
Assignees
Reporter firewave
    ```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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to