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

Function nextAfterAstRightmostLeafGeneric

lib/astutils.cpp:546–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544}
545
546template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
547static T* nextAfterAstRightmostLeafGeneric(T* tok)
548{
549 T * rightmostLeaf = tok;
550 if (!rightmostLeaf || !rightmostLeaf->astOperand1())
551 return nullptr;
552 do {
553 if (T* lam = findLambdaEndToken(rightmostLeaf)) {
554 rightmostLeaf = lam;
555 break;
556 }
557 if (rightmostLeaf->astOperand2() && precedes(rightmostLeaf, rightmostLeaf->astOperand2()))
558 rightmostLeaf = rightmostLeaf->astOperand2();
559 else if (rightmostLeaf->astOperand1() && precedes(rightmostLeaf, rightmostLeaf->astOperand1()))
560 rightmostLeaf = rightmostLeaf->astOperand1();
561 else
562 break;
563 } while (rightmostLeaf->astOperand1() || rightmostLeaf->astOperand2());
564 while (Token::Match(rightmostLeaf->next(), "]|)") && !hasToken(rightmostLeaf->linkAt(1), rightmostLeaf->next(), tok))
565 rightmostLeaf = rightmostLeaf->next();
566 if (Token::Match(rightmostLeaf, "{|(|[") && rightmostLeaf->link())
567 rightmostLeaf = rightmostLeaf->link();
568 return rightmostLeaf->next();
569}
570
571const Token* nextAfterAstRightmostLeaf(const Token* tok)
572{

Callers 2

isVariableChangedFunction · 0.85

Calls 7

findLambdaEndTokenFunction · 0.85
precedesFunction · 0.85
hasTokenFunction · 0.85
astOperand1Method · 0.80
astOperand2Method · 0.80
nextMethod · 0.80
linkAtMethod · 0.80

Tested by

no test coverage detected