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

Function isVariableInit

lib/valueflow.cpp:4084–4105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4082}
4083
4084static bool isVariableInit(const Token *tok)
4085{
4086 if (!tok)
4087 return false;
4088 if (!Token::Match(tok->previous(), "%var% (|{"))
4089 return false;
4090 if (!tok->isBinaryOp() && !(tok->astOperand1() && tok->link() == tok->next()))
4091 return false;
4092 if (Token::simpleMatch(tok->astOperand2(), ","))
4093 return false;
4094 const Variable* var = tok->astOperand1()->variable();
4095 if (!var)
4096 return false;
4097 if (var->nameToken() != tok->astOperand1())
4098 return false;
4099 const ValueType* vt = var->valueType();
4100 if (!vt)
4101 return false;
4102 if (vt->type < ValueType::Type::VOID)
4103 return false;
4104 return true;
4105}
4106
4107// Return true if two associative containers intersect
4108template<class C1, class C2>

Callers 1

valueFlowAfterAssignFunction · 0.85

Calls 7

isBinaryOpMethod · 0.80
astOperand1Method · 0.80
nextMethod · 0.80
astOperand2Method · 0.80
variableMethod · 0.80
simpleMatchFunction · 0.70
nameTokenMethod · 0.45

Tested by

no test coverage detected