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

Function checkEvaluationOrderCpp11

lib/checkother.cpp:3817–3837  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3815}
3816
3817static bool checkEvaluationOrderCpp11(const Token * tok, const Token * tok2, const Token * parent, const Settings & settings)
3818{
3819 if (tok->isAssignmentOp()) // TODO check assignment
3820 return false;
3821 if (tok->previous() == tok->astOperand1() && parent->isArithmeticalOp() && parent->isBinaryOp()) {
3822 if (parent->astParent() && parent->astParent()->isAssignmentOp() && isSameExpression(false, tok->astOperand1(), parent->astParent()->astOperand1(), settings, true, false))
3823 return true;
3824 }
3825 bool foundUndefined{false};
3826 visitAstNodes((parent->astOperand1() != tok2) ? parent->astOperand1() : parent->astOperand2(), [&](const Token *tok3) {
3827 if (tok3->str() == "&" && !tok3->astOperand2())
3828 return ChildrenToVisit::none; // don't handle address-of for now
3829 if (tok3->str() == "(" && Token::simpleMatch(tok3->previous(), "sizeof"))
3830 return ChildrenToVisit::none; // don't care about sizeof usage
3831 if (isSameExpression(false, tok->astOperand1(), tok3, settings, true, false))
3832 foundUndefined = true;
3833 return foundUndefined ? ChildrenToVisit::done : ChildrenToVisit::op1_and_op2;
3834 });
3835
3836 return foundUndefined;
3837}
3838
3839static bool checkEvaluationOrderCpp17(const Token * tok, const Token * tok2, const Token * parent, const Settings & settings, bool & foundUnspecified)
3840{

Callers 1

checkEvaluationOrderMethod · 0.85

Calls 10

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

Tested by

no test coverage detected