Refactoring: Use visitAstNodes

This commit is contained in:
Daniel Marjamäki 2018-11-23 17:18:07 +01:00
parent 344424b759
commit 745b58de26
1 changed files with 10 additions and 12 deletions

View File

@ -284,22 +284,20 @@ static const Token * skipValueInConditionalExpression(const Token * const valuet
continue; continue;
// Is variable protected in LHS.. // Is variable protected in LHS..
std::stack<const Token *> tokens; bool bailout = false;
tokens.push(tok->astOperand1()); visitAstNodes(tok->astOperand1(), [&](const Token *tok2) {
while (!tokens.empty()) { if (tok2->str() == ".")
const Token * const tok2 = tokens.top(); return ChildrenToVisit::none;
tokens.pop();
if (!tok2 || tok2->str() == ".")
continue;
// A variable is seen.. // A variable is seen..
if (tok2 != valuetok && tok2->variable() && (tok2->varId() == valuetok->varId() || !tok2->variable()->isArgument())) { if (tok2 != valuetok && tok2->variable() && (tok2->varId() == valuetok->varId() || !tok2->variable()->isArgument())) {
// TODO: limit this bailout // TODO: limit this bailout
return tok; bailout = true;
return ChildrenToVisit::done;
} }
tokens.push(tok2->astOperand2()); return ChildrenToVisit::op1_and_op2;
tokens.push(tok2->astOperand1()); });
} if (bailout)
return tok;
} }
return nullptr; return nullptr;
} }