MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / isNullOperand

Function isNullOperand

lib/astutils.cpp:3660–3672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3658}
3659
3660bool isNullOperand(const Token *expr)
3661{
3662 if (!expr)
3663 return false;
3664 if (expr->isCpp() && Token::Match(expr, "static_cast|const_cast|dynamic_cast|reinterpret_cast <"))
3665 expr = expr->astParent();
3666 else if (!expr->isCast())
3667 return Token::Match(expr, "NULL|nullptr");
3668 if (expr->valueType() && expr->valueType()->pointer == 0)
3669 return false;
3670 const Token *castOp = expr->astOperand2() ? expr->astOperand2() : expr->astOperand1();
3671 return Token::Match(castOp, "NULL|nullptr") || (MathLib::isInt(castOp->str()) && MathLib::isNullValue(castOp->str()));
3672}
3673
3674bool isGlobalData(const Token *expr)
3675{

Callers 5

isSimpleExprFunction · 0.85
constStatementErrorMethod · 0.85
isNullOperandTestMethod · 0.85

Calls 5

astParentMethod · 0.80
isCastMethod · 0.80
astOperand2Method · 0.80
astOperand1Method · 0.80
strMethod · 0.45

Tested by 1

isNullOperandTestMethod · 0.68