Refactoring; Use visitAstNodes

This commit is contained in:
Daniel Marjamäki 2018-11-23 20:41:39 +01:00
parent 2b09354b05
commit b049a31e7c
1 changed files with 6 additions and 12 deletions

View File

@ -510,18 +510,12 @@ void CheckCondition::multiCondition2()
bool nonConstFunctionCall = false; bool nonConstFunctionCall = false;
bool nonlocal = false; // nonlocal variable used in condition bool nonlocal = false; // nonlocal variable used in condition
std::set<unsigned int> vars; // variables used in condition std::set<unsigned int> vars; // variables used in condition
std::stack<const Token *> tokens; visitAstNodes(condTok,
tokens.push(condTok); [&](const Token *cond) {
while (!tokens.empty()) {
const Token *cond = tokens.top();
tokens.pop();
if (!cond)
continue;
if (Token::Match(cond, "%name% (")) { if (Token::Match(cond, "%name% (")) {
nonConstFunctionCall = isNonConstFunctionCall(cond, mSettings->library); nonConstFunctionCall = isNonConstFunctionCall(cond, mSettings->library);
if (nonConstFunctionCall) if (nonConstFunctionCall)
break; return ChildrenToVisit::done;
} }
if (cond->varId()) { if (cond->varId()) {
@ -538,10 +532,10 @@ void CheckCondition::multiCondition2()
// varid is 0. this is possibly a nonlocal variable.. // varid is 0. this is possibly a nonlocal variable..
nonlocal = Token::Match(cond->astParent(), "%cop%|(|[") || Token::Match(cond, "%name% .") || (mTokenizer->isCPP() && cond->str() == "this"); nonlocal = Token::Match(cond->astParent(), "%cop%|(|[") || Token::Match(cond, "%name% .") || (mTokenizer->isCPP() && cond->str() == "this");
} else { } else {
tokens.push(cond->astOperand1()); return ChildrenToVisit::op1_and_op2;
tokens.push(cond->astOperand2());
} }
} return ChildrenToVisit::none;
});
if (nonConstFunctionCall) if (nonConstFunctionCall)
continue; continue;