From caebf137bc8e84a58324fd4b358300cd43618372 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Tue, 12 Sep 2017 00:21:36 +0300 Subject: [PATCH] Cache and reuse value --- lib/valueflow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 246e2ca31..4336d2433 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -917,7 +917,8 @@ static void valueFlowOppositeCondition(SymbolDatabase *symboldatabase, const Set tok2 = tok2->linkAt(1); if (!Token::simpleMatch(tok2, "} else { if (")) break; - const Token *cond2 = tok2->tokAt(4)->astOperand2(); + const Token *ifOpenBraceTok = tok2->tokAt(4); + const Token *cond2 = ifOpenBraceTok->astOperand2(); if (!cond2 || !cond2->isComparisonOp()) continue; if (isOppositeCond(true, cpp, cond1, cond2, settings->library, true)) { @@ -925,7 +926,7 @@ static void valueFlowOppositeCondition(SymbolDatabase *symboldatabase, const Set value.setKnown(); setTokenValue(const_cast(cond2), value, settings); } - tok2 = tok2->linkAt(4); + tok2 = ifOpenBraceTok->link(); } } }