Clarify code with Token::isUnaryOp()

This commit is contained in:
Daniel Marjamäki 2018-07-14 22:36:08 +02:00
parent 1e824330c0
commit 991300ac54
1 changed files with 3 additions and 3 deletions

View File

@ -965,7 +965,7 @@ static void valueFlowPointerAlias(TokenList *tokenlist)
{ {
for (Token *tok = tokenlist->front(); tok; tok = tok->next()) { for (Token *tok = tokenlist->front(); tok; tok = tok->next()) {
// not address of // not address of
if (tok->str() != "&" || tok->astOperand2()) if (!tok->isUnaryOp("&"))
continue; continue;
// parent should be a '=' // parent should be a '='
@ -2121,7 +2121,7 @@ static bool valueFlowForward(Token * const startToken,
} }
// bailout if address of var is taken.. // bailout if address of var is taken..
if (tok2->astParent() && tok2->astParent()->str() == "&" && !tok2->astParent()->astOperand2()) { if (tok2->astParent() && tok2->astParent()->isUnaryOp("&")) {
if (settings->debugwarnings) if (settings->debugwarnings)
bailout(tokenlist, errorLogger, tok2, "Taking address of " + tok2->str()); bailout(tokenlist, errorLogger, tok2, "Taking address of " + tok2->str());
return false; return false;
@ -2321,7 +2321,7 @@ static void valueFlowAfterAssign(TokenList *tokenlist, SymbolDatabase* symboldat
std::set<unsigned int> aliased; std::set<unsigned int> aliased;
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
// Alias // Alias
if (tok->str() == "&" && !tok->astOperand2() && tok->astOperand1()) { if (tok->isUnaryOp("&")) {
aliased.insert(tok->astOperand1()->varId()); aliased.insert(tok->astOperand1()->varId());
continue; continue;
} }