From dfd19233e9449d2b4dd46d63e67885c5233a4a64 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 9 Feb 2015 14:40:17 +0300 Subject: [PATCH] Simplify loop logic --- lib/valueflow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index b11b4f29a..facb57ec2 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1141,10 +1141,10 @@ static void valueFlowAfterCondition(TokenList *tokenlist, SymbolDatabase* symbol if (parent->astOperand1() == tok && ((op == "&&" && Token::Match(tok, "==|>=|<=|!")) || (op == "||" && Token::Match(tok, "%name%|!=")))) { - bool assign = false; - for (; !assign && parent && parent->str() == op; parent = const_cast(parent->astParent())) { + for (; parent && parent->str() == op; parent = const_cast(parent->astParent())) { std::stack tokens; tokens.push(const_cast(parent->astOperand2())); + bool assign = false; while (!tokens.empty()) { Token *rhstok = tokens.top(); tokens.pop(); @@ -1159,6 +1159,8 @@ static void valueFlowAfterCondition(TokenList *tokenlist, SymbolDatabase* symbol break; } } + if (assign) + break; while (parent->astParent() && parent == parent->astParent()->astOperand2()) parent = const_cast(parent->astParent()); }