| 2124 | } |
| 2125 | |
| 2126 | bool isConstExpression(const Token *tok, const Library& library) |
| 2127 | { |
| 2128 | if (!tok) |
| 2129 | return true; |
| 2130 | if (tok->variable() && tok->variable()->isVolatile()) |
| 2131 | return false; |
| 2132 | if (tok->isName() && tok->strAt(1) == "(") { |
| 2133 | if (!isConstFunctionCall(tok, library)) |
| 2134 | return false; |
| 2135 | } |
| 2136 | if (tok->tokType() == Token::eIncDecOp) |
| 2137 | return false; |
| 2138 | if (tok->isAssignmentOp()) |
| 2139 | return false; |
| 2140 | if (isLikelyStreamRead(tok)) |
| 2141 | return false; |
| 2142 | // bailout when we see ({..}) |
| 2143 | if (tok->str() == "{") |
| 2144 | return false; |
| 2145 | return isConstExpression(tok->astOperand1(), library) && isConstExpression(tok->astOperand2(), library); |
| 2146 | } |
| 2147 | |
| 2148 | bool isWithoutSideEffects(const Token* tok, bool checkArrayAccess, bool checkReference) |
| 2149 | { |
no test coverage detected