From 84581817f66a39dd593c79aaada9c36f82fd7add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 18 Jun 2014 21:07:01 +0200 Subject: [PATCH] ValueFlow: Improved valueFlowForward. RHS in assignment. --- lib/valueflow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index e0946d304..e3952938d 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -659,6 +659,15 @@ static bool valueFlowForward(Token * const startToken, if (tok2->varId() == varid) { // bailout: assignment if (Token::Match(tok2->previous(), "!!* %var% %op%") && tok2->next()->isAssignmentOp()) { + // simplify rhs + for (Token *tok3 = tok2->tokAt(2); tok3; tok3 = tok3->next()) { + if (tok3->varId() == varid) { + std::list::const_iterator it; + for (it = values.begin(); it != values.end(); ++it) + setTokenValue(tok2, *it); + } else if (Token::Match(tok3, "++|--|?|:|;")) + break; + } if (settings->debugwarnings) bailout(tokenlist, errorLogger, tok2, "assignment of " + tok2->str()); return false;