ast: clarify the code somewhat
This commit is contained in:
parent
bce99a9e2f
commit
d5af34331b
|
@ -1066,12 +1066,16 @@ void Token::astFunctionCall()
|
||||||
|
|
||||||
void Token::astHandleParentheses()
|
void Token::astHandleParentheses()
|
||||||
{
|
{
|
||||||
|
// Assumptions:
|
||||||
|
// * code is valid
|
||||||
|
// * _str is one of: ( ) ]
|
||||||
|
|
||||||
Token *innerTop;
|
Token *innerTop;
|
||||||
if (_str != "(")
|
if (Token::Match(this, ")|]"))
|
||||||
innerTop = _previous;
|
innerTop = _previous;
|
||||||
else if (_next && _next->_str == ")")
|
else if (_next && _next->_str == ")")
|
||||||
return;
|
return;
|
||||||
else
|
else // _str = "("
|
||||||
innerTop = _next;
|
innerTop = _next;
|
||||||
while (innerTop->_astParent)
|
while (innerTop->_astParent)
|
||||||
innerTop = innerTop->_astParent;
|
innerTop = innerTop->_astParent;
|
||||||
|
|
|
@ -412,7 +412,7 @@ void TokenList::createAst()
|
||||||
|
|
||||||
// parentheses..
|
// parentheses..
|
||||||
for (Token *tok = _front; tok; tok = tok->next()) {
|
for (Token *tok = _front; tok; tok = tok->next()) {
|
||||||
if (tok->str() == "(" || tok->str() == ")" || tok->str() == "]") {
|
if (Token::Match(tok, "(|)|]")) {
|
||||||
tok->astHandleParentheses();
|
tok->astHandleParentheses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue