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

Function findAllocFuncCallToken

lib/astutils.cpp:3645–3658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3643}
3644
3645const Token* findAllocFuncCallToken(const Token *expr, const Library &library)
3646{
3647 if (!expr)
3648 return nullptr;
3649 if (Token::Match(expr, "[+-]")) {
3650 const Token *tok1 = findAllocFuncCallToken(expr->astOperand1(), library);
3651 return tok1 ? tok1 : findAllocFuncCallToken(expr->astOperand2(), library);
3652 }
3653 if (expr->isCast())
3654 return findAllocFuncCallToken(expr->astOperand2() ? expr->astOperand2() : expr->astOperand1(), library);
3655 if (Token::Match(expr->previous(), "%name% (") && library.getAllocFuncInfo(expr->astOperand1()))
3656 return expr->astOperand1();
3657 return (Token::simpleMatch(expr, "new") && expr->astOperand1()) ? expr : nullptr;
3658}
3659
3660bool isNullOperand(const Token *expr)
3661{

Callers 2

checkScopeMethod · 0.85

Calls 5

astOperand1Method · 0.80
astOperand2Method · 0.80
isCastMethod · 0.80
getAllocFuncInfoMethod · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected