Refactoring; Use Token::isUnaryOp() to clarify code

This commit is contained in:
Daniel Marjamäki 2018-07-13 23:02:52 +02:00
parent 5712366a8f
commit a4fdef8d9e
1 changed files with 2 additions and 2 deletions

View File

@ -106,7 +106,7 @@ static bool isAutoVarArray(const Token *tok)
return false; return false;
// &x[..] // &x[..]
if (tok->str() == "&" && Token::simpleMatch(tok->astOperand1(), "[") && !tok->astOperand2()) if (tok->isUnaryOp("&") && Token::simpleMatch(tok->astOperand1(), "["))
return isAutoVarArray(tok->astOperand1()->astOperand1()); return isAutoVarArray(tok->astOperand1()->astOperand1());
// x+y // x+y
@ -474,7 +474,7 @@ static bool astHasAutoResult(const Token *tok)
return false; return false;
if ((tok->str() == "<<" || tok->str() == ">>") && tok->astOperand1()) { if ((tok->str() == "<<" || tok->str() == ">>") && tok->astOperand1()) {
const Token* tok2 = tok->astOperand1(); const Token* tok2 = tok->astOperand1();
while (tok2 && tok2->str() == "*" && !tok2->astOperand2()) while (tok2 && tok2->isUnaryOp("*"))
tok2 = tok2->astOperand1(); tok2 = tok2->astOperand1();
return tok2 && tok2->variable() && !tok2->variable()->isClass() && !tok2->variable()->isStlType(); // Class or unknown type on LHS: Assume it is a stream return tok2 && tok2->variable() && !tok2->variable()->isClass() && !tok2->variable()->isStlType(); // Class or unknown type on LHS: Assume it is a stream
} }