Refactoring; use visitAstNodes
This commit is contained in:
parent
2214ef5359
commit
2b09354b05
|
@ -1547,26 +1547,23 @@ bool CheckClass::hasAssignSelf(const Function *func, const Token *rhs)
|
||||||
if (!Token::simpleMatch(tok, "if ("))
|
if (!Token::simpleMatch(tok, "if ("))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::stack<const Token *> tokens;
|
bool ret = false;
|
||||||
tokens.push(tok->next()->astOperand2());
|
visitAstNodes(tok->next()->astOperand2(),
|
||||||
while (!tokens.empty()) {
|
[&](const Token *tok2) {
|
||||||
const Token *tok2 = tokens.top();
|
|
||||||
tokens.pop();
|
|
||||||
if (!tok2)
|
|
||||||
continue;
|
|
||||||
tokens.push(tok2->astOperand1());
|
|
||||||
tokens.push(tok2->astOperand2());
|
|
||||||
if (!Token::Match(tok2, "==|!="))
|
if (!Token::Match(tok2, "==|!="))
|
||||||
continue;
|
return ChildrenToVisit::op1_and_op2;
|
||||||
if (Token::simpleMatch(tok2->astOperand1(), "this"))
|
if (Token::simpleMatch(tok2->astOperand1(), "this"))
|
||||||
tok2 = tok2->astOperand2();
|
tok2 = tok2->astOperand2();
|
||||||
else if (Token::simpleMatch(tok2->astOperand2(), "this"))
|
else if (Token::simpleMatch(tok2->astOperand2(), "this"))
|
||||||
tok2 = tok2->astOperand1();
|
tok2 = tok2->astOperand1();
|
||||||
else
|
else
|
||||||
continue;
|
return ChildrenToVisit::op1_and_op2;
|
||||||
if (tok2 && tok2->isUnaryOp("&") && tok2->astOperand1()->str() == rhs->str())
|
if (tok2 && tok2->isUnaryOp("&") && tok2->astOperand1()->str() == rhs->str())
|
||||||
return true;
|
ret = true;
|
||||||
}
|
return ret ? ChildrenToVisit::done : ChildrenToVisit::op1_and_op2;
|
||||||
|
});
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue