From 991300ac549e00bdd272f9f5cf85854b08025ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 14 Jul 2018 22:36:08 +0200 Subject: [PATCH] Clarify code with Token::isUnaryOp() --- lib/valueflow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 9ac2cbf18..194153001 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -965,7 +965,7 @@ static void valueFlowPointerAlias(TokenList *tokenlist) { for (Token *tok = tokenlist->front(); tok; tok = tok->next()) { // not address of - if (tok->str() != "&" || tok->astOperand2()) + if (!tok->isUnaryOp("&")) continue; // parent should be a '=' @@ -2121,7 +2121,7 @@ static bool valueFlowForward(Token * const startToken, } // 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) bailout(tokenlist, errorLogger, tok2, "Taking address of " + tok2->str()); return false; @@ -2321,7 +2321,7 @@ static void valueFlowAfterAssign(TokenList *tokenlist, SymbolDatabase* symboldat std::set aliased; for (Token* tok = const_cast(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { // Alias - if (tok->str() == "&" && !tok->astOperand2() && tok->astOperand1()) { + if (tok->isUnaryOp("&")) { aliased.insert(tok->astOperand1()->varId()); continue; }