For the following code (wrong.cpp):

bool check(bool isValid)
{
    bool retVal = false;

    if (( isValid == true ))
    {
        retVal = true;
    }

    return retVal;
}

when I run:
    clang-tidy -checks=modernize-use-default-member-init wrong.cpp

I get:
4 warnings and 1 error generated.
Error while processing /llvm/match/ctBad/wrong.cpp.
/llvm/match/ctBad/wrong.cpp:5:19: error: equality comparison with
extraneous parentheses [clang-diagnostic-parentheses-equality]
    if (( isValid == true ))
        ~         ^~      ~
                  =
/llvm/match/ctBad/wrong.cpp:5:19: note: remove extraneous parentheses
around the comparison to silence this warning
/llvm/match/ctBad/wrong.cpp:5:19: note: use '=' to turn this equality
comparison into an assignment

Note it turns the if into:
    if ( isValid = true )

Seems like a very bad idea. Removing the redundant parentheses seems fine,
but changing the comparison to an assignment does not. Is this a bug?

Thanks,
Robert
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to