[clang-tidy] `readability-redundant-parentheses` conflicts with suggested `-Wunreachable-code` mitigation
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```cpp
void f(bool b)
{
if (false && b) {}
}
```
The code above will report the following:
```
:3:18: warning: code will never be executed [-Wunreachable-code]
3 | if (false && b) {}
| ^
:3:9: note: silence by adding parentheses to mark code as explicitly dead
3 | if (false && b) {}
| ^
| /* DISABLES CODE */ ( )
```
But addressing that as suggested will lead to a clang-tidy warning:
```
:3:9: warning: redundant parentheses around expression [readability-redundant-parentheses]
3 | if ((false) && b) {}
| ^ ~
```
https://godbolt.org/z/nTvEGrr7c
Contributor guide
Research direction
Start by reproducing the diagnostic interaction with the C++ example and the linked Compiler Explorer case. Then inspect clang-tidy's readability-redundant-parentheses check and its regression tests; done means the suggested -Wunreachable-code mitigation no longer produces a contradictory clang-tidy warning, with coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100