Skip to content

[Clang-Tidy] Create readability-math-missing-parentheses check #80850

Closed
@PiotrZSL

Description

@PiotrZSL

I'm adding this here so, i woudn't forget.
Create check that detect missing () around mathematical expressions when operators of different priority are used.

int main()
{
    return 2 + 2 * 2;
}

Should be:

int main()
{
    return 2 + (2 * 2);
}

Similar thing for other math operators.
Main purpose is to explicitly show evaluation order.
Consider adding option to skip constructions that properly handled from left to right like: 2 * 2 + 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions