Skip to content

readability-simplify-boolean-expr doesn't handle if condition variables or init statements #55553

@njames93

Description

@njames93

The check doesn't handle condition variables or c++17 if init statements resulting in malformed code.

    if (bool X = Cond)
      Result = true;
    else
      Result = false;
    // Transformed to Result = X;

    if (bool X = Cond)
      return true;
    return false;
    // Transformed to return X;

    if (RAII Object; Cond)
      Result = true;
    else
      Result = false;
    // Transformed to Result = Cond; -> Removing the RAII object instance

    if (bool X = Cond; X)
      Result = true;
    else
      Result = false;
    // Transformed to Result = X;

    if (bool X = Cond; X)
      return true;
    return false;
    // Transformed to return X;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions