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

Function getLHSVariablesRecursive

lib/astutils.cpp:3568–3587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3566}
3567
3568static void getLHSVariablesRecursive(std::vector<const Variable*>& vars, const Token* tok)
3569{
3570 if (!tok)
3571 return;
3572 if (vars.empty() && Token::Match(tok, "*|&|&&|[")) {
3573 getLHSVariablesRecursive(vars, tok->astOperand1());
3574 if (!vars.empty() || Token::simpleMatch(tok, "["))
3575 return;
3576 getLHSVariablesRecursive(vars, tok->astOperand2());
3577 } else if (Token::Match(tok->previous(), "this . %var%")) {
3578 getLHSVariablesRecursive(vars, tok->next());
3579 } else if (Token::simpleMatch(tok, ".")) {
3580 getLHSVariablesRecursive(vars, tok->astOperand1());
3581 getLHSVariablesRecursive(vars, tok->astOperand2());
3582 } else if (Token::simpleMatch(tok, "::")) {
3583 getLHSVariablesRecursive(vars, tok->astOperand2());
3584 } else if (tok->variable()) {
3585 vars.push_back(tok->variable());
3586 }
3587}
3588
3589std::vector<const Variable*> getLHSVariables(const Token* tok)
3590{

Callers 1

getLHSVariablesFunction · 0.85

Calls 7

astOperand1Method · 0.80
astOperand2Method · 0.80
nextMethod · 0.80
variableMethod · 0.80
simpleMatchFunction · 0.70
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected