Mathias Schmid - 2021-01-27

I use a Python script for some checks based on Cppcheck dump-files. The following functions are functional equal. The second function contains some unnecessary lines of code but in the dump-file the lambda function is missing.
Used version: Cppcheck 2.3 (Windows 10).

First function and dump-file extract:

bool hasMember()
{
    return (std::any_of(memberList.cbegin(), memberList.cend(), [](MemberTag tag) { return (tag != MemberTag::NoMember); } ));
}

<scope id="000001D110D55810" type="Function" className="hasMember" bodyStart="000001D110E00710" bodyEnd="000001D1129C3BC0" nestedIn="000001D110D54A40" function="000001D11296BF40">
  <functionList>
    <function id="000001D110DFE650" tokenDef="000001D110E00FB0" name="[" type="Lambda">
      <arg nr="1" variable="000001D112C75870"/>
    </function>
  </functionList>
</scope>

Second Function and dump-file extract:

bool hasMember_MissingLambda()
{
    bool retVal = false;
    if (std::any_of(memberList.cbegin(), memberList.cend(), [](MemberTag tag) { return (tag != MemberTag::NoMember); } ))
    {
        retVal = true;
    }
    return retVal;
}

<scope id="000001D110D55700" type="Function" className="hasMember_MissingLambda" bodyStart="000001D1129C3260" bodyEnd="000001D1129C3140" nestedIn="000001D110D54A40" function="000001D110DFF5F0">
  <varlist><var id="000001D112C76BB0"/></varlist>
</scope>
 

Last edit: Mathias Schmid 2021-01-27