MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / checkEvaluationOrderCpp17

Function checkEvaluationOrderCpp17

lib/checkother.cpp:3839–3861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3837}
3838
3839static bool checkEvaluationOrderCpp17(const Token * tok, const Token * tok2, const Token * parent, const Settings & settings, bool & foundUnspecified)
3840{
3841 if (tok->isAssignmentOp())
3842 return false;
3843 bool foundUndefined{false};
3844 visitAstNodes((parent->astOperand1() != tok2) ? parent->astOperand1() : parent->astOperand2(), [&](const Token *tok3) {
3845 if (tok3->str() == "&" && !tok3->astOperand2())
3846 return ChildrenToVisit::none; // don't handle address-of for now
3847 if (tok3->str() == "(" && Token::simpleMatch(tok3->previous(), "sizeof"))
3848 return ChildrenToVisit::none; // don't care about sizeof usage
3849 if (isSameExpression(false, tok->astOperand1(), tok3, settings, true, false) && parent->isArithmeticalOp() && parent->isBinaryOp())
3850 foundUndefined = true;
3851 if (tok3->tokType() == Token::eIncDecOp && isSameExpression(false, tok->astOperand1(), tok3->astOperand1(), settings, true, false)) {
3852 if (parent->isArithmeticalOp() && parent->isBinaryOp())
3853 foundUndefined = true;
3854 else
3855 foundUnspecified = true;
3856 }
3857 return (foundUndefined || foundUnspecified) ? ChildrenToVisit::done : ChildrenToVisit::op1_and_op2;
3858 });
3859
3860 return foundUndefined || foundUnspecified;
3861}
3862
3863void CheckOtherImpl::checkEvaluationOrder()
3864{

Callers 1

checkEvaluationOrderMethod · 0.85

Calls 9

visitAstNodesFunction · 0.85
isSameExpressionFunction · 0.85
isAssignmentOpMethod · 0.80
astOperand1Method · 0.80
astOperand2Method · 0.80
isArithmeticalOpMethod · 0.80
isBinaryOpMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected