[clang-tidy] readability-implicit-bool-conversion.AllowPointerConditions doesn't work on more complex expressions
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```c++
struct Obj {
int data;
}
void foo(Obj* obj) {
// OK
if (obj) {
if (obj->data == 42) {
}
}
// Warning
if (obj && obj->data == 42) {
}
}
```
If pointer is dereferenced in the same conditional expression after null pointer check then clang-tidy warns even if `readability-implicit-bool-conversion.AllowPointerConditions` is set to true. I believe that this option should allow this too.
Contributor guide
Research direction
Start by reproducing the provided C++ example with clang-tidy's readability-implicit-bool-conversion check and AllowPointerConditions enabled. Trace how the check handles a pointer dereference after a null check within the same conditional expression. Done means the combined condition no longer warns when this option is enabled, with coverage for the reported 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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100