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

Function findAstTop

lib/tokenlist.cpp:1575–1593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1573}
1574
1575static Token * findAstTop(Token *tok1, const Token *tok2)
1576{
1577 for (Token *tok = tok1; tok && (tok != tok2); tok = tok->next()) {
1578 if (tok->astParent() || tok->astOperand1() || tok->astOperand2()) {
1579 while (tok->astParent() && tok->astParent()->index() >= tok1->index() && tok->astParent()->index() <= tok2->index())
1580 tok = tok->astParent();
1581 return tok;
1582 }
1583 if (Token::simpleMatch(tok, "( {"))
1584 tok = tok->link();
1585 }
1586 for (Token *tok = tok1; tok && (tok != tok2); tok = tok->next()) {
1587 if (tok->isName() || tok->isNumber())
1588 return tok;
1589 if (Token::simpleMatch(tok, "( {"))
1590 tok = tok->link();
1591 }
1592 return nullptr;
1593}
1594
1595static Token *skipMethodDeclEnding(Token *tok)
1596{

Callers 1

createAstAtTokenFunction · 0.85

Calls 5

nextMethod · 0.80
astParentMethod · 0.80
astOperand1Method · 0.80
astOperand2Method · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected