Refactoring; use visitAstNodes

This commit is contained in:
Daniel Marjamäki 2018-11-23 19:22:53 +01:00
parent 52f9650533
commit 8f164d9602
1 changed files with 7 additions and 14 deletions

View File

@ -2734,23 +2734,16 @@ void CheckOther::checkEvaluationOrder()
// Is expression used?
bool foundError = false;
std::stack<const Token *> tokens;
tokens.push((parent->astOperand1() != tok2) ? parent->astOperand1() : parent->astOperand2());
while (!tokens.empty() && !foundError) {
const Token * const tok3 = tokens.top();
tokens.pop();
if (!tok3)
continue;
visitAstNodes((parent->astOperand1() != tok2) ? parent->astOperand1() : parent->astOperand2(),
[&](const Token *tok3) {
if (tok3->str() == "&" && !tok3->astOperand2())
continue; // don't handle address-of for now
return ChildrenToVisit::none; // don't handle address-of for now
if (tok3->str() == "(" && Token::simpleMatch(tok3->previous(), "sizeof"))
continue; // don't care about sizeof usage
tokens.push(tok3->astOperand1());
tokens.push(tok3->astOperand2());
if (isSameExpression(mTokenizer->isCPP(), false, tok->astOperand1(), tok3, mSettings->library, true, false)) {
return ChildrenToVisit::none; // don't care about sizeof usage
if (isSameExpression(mTokenizer->isCPP(), false, tok->astOperand1(), tok3, mSettings->library, true, false))
foundError = true;
}
}
return foundError ? ChildrenToVisit::done : ChildrenToVisit::op1_and_op2;
});
if (foundError) {
unknownEvaluationOrder(parent);