Merge pull request #516 from Dmitry-Me/simplifyLoopLogic
Simplify loop logic
This commit is contained in:
commit
efd2f51cba
|
@ -1141,10 +1141,10 @@ static void valueFlowAfterCondition(TokenList *tokenlist, SymbolDatabase* symbol
|
||||||
if (parent->astOperand1() == tok &&
|
if (parent->astOperand1() == tok &&
|
||||||
((op == "&&" && Token::Match(tok, "==|>=|<=|!")) ||
|
((op == "&&" && Token::Match(tok, "==|>=|<=|!")) ||
|
||||||
(op == "||" && Token::Match(tok, "%name%|!=")))) {
|
(op == "||" && Token::Match(tok, "%name%|!=")))) {
|
||||||
bool assign = false;
|
for (; parent && parent->str() == op; parent = const_cast<Token*>(parent->astParent())) {
|
||||||
for (; !assign && parent && parent->str() == op; parent = const_cast<Token*>(parent->astParent())) {
|
|
||||||
std::stack<Token *> tokens;
|
std::stack<Token *> tokens;
|
||||||
tokens.push(const_cast<Token*>(parent->astOperand2()));
|
tokens.push(const_cast<Token*>(parent->astOperand2()));
|
||||||
|
bool assign = false;
|
||||||
while (!tokens.empty()) {
|
while (!tokens.empty()) {
|
||||||
Token *rhstok = tokens.top();
|
Token *rhstok = tokens.top();
|
||||||
tokens.pop();
|
tokens.pop();
|
||||||
|
@ -1159,6 +1159,8 @@ static void valueFlowAfterCondition(TokenList *tokenlist, SymbolDatabase* symbol
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (assign)
|
||||||
|
break;
|
||||||
while (parent->astParent() && parent == parent->astParent()->astOperand2())
|
while (parent->astParent() && parent == parent->astParent()->astOperand2())
|
||||||
parent = const_cast<Token*>(parent->astParent());
|
parent = const_cast<Token*>(parent->astParent());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue