Skip to content

[clang-tidy] readability-implicit-bool-conversion.AllowPointerConditions doesn't work on more complex expressions #160373

@equeim

Description

@equeim
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions