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

Method isCalculation

lib/token.cpp:1541–1575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1539}
1540
1541bool Token::isCalculation() const
1542{
1543 if (!Token::Match(this, "%cop%|++|--"))
1544 return false;
1545
1546 if (Token::Match(this, "*|&")) {
1547 // dereference or address-of?
1548 if (!this->astOperand2())
1549 return false;
1550
1551 if (this->astOperand2()->str() == "[")
1552 return false;
1553
1554 // type specification?
1555 std::stack<const Token *> operands;
1556 operands.push(this);
1557 while (!operands.empty()) {
1558 const Token *op = operands.top();
1559 operands.pop();
1560 if (op->isNumber() || op->varId() > 0)
1561 return true;
1562 if (op->astOperand1())
1563 operands.push(op->astOperand1());
1564 if (op->astOperand2())
1565 operands.push(op->astOperand2());
1566 else if (Token::Match(op, "*|&"))
1567 return false;
1568 }
1569
1570 // type specification => return false
1571 return false;
1572 }
1573
1574 return true;
1575}
1576
1577bool Token::isUnaryPreOp() const
1578{

Callers 3

clarifyCalculationMethod · 0.80
checkConstVariableMethod · 0.80
sizeofCalculationMethod · 0.80

Calls 4

astOperand2Method · 0.95
astOperand1Method · 0.80
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected