[cfe-users] clang-tidy bug?

Robert Ankeney via cfe-users cfe-users at lists.llvm.org
Sun Oct 27 11:31:54 PDT 2019


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20191027/3929ed8b/attachment.html>


More information about the cfe-users mailing list