| 207 | } |
| 208 | |
| 209 | virtual Action isModified(const Token* tok) const { |
| 210 | const ValueFlow::Value* value = getValue(tok); |
| 211 | if (value) { |
| 212 | // Moving a moved value won't change the moved value |
| 213 | if (value->isMovedValue() && isMoveOrForward(tok) != ValueFlow::Value::MoveKind::NonMovedVariable) |
| 214 | return Action::Read; |
| 215 | // Inserting elements to container won't change the lifetime |
| 216 | if (astIsContainer(tok) && value->isLifetimeValue() && |
| 217 | contains({Library::Container::Action::PUSH, |
| 218 | Library::Container::Action::INSERT, |
| 219 | Library::Container::Action::APPEND, |
| 220 | Library::Container::Action::CHANGE_INTERNAL}, |
| 221 | astContainerAction(tok, getSettings().library))) |
| 222 | return Action::Read; |
| 223 | } |
| 224 | bool inconclusive = false; |
| 225 | if (isVariableChangedByFunctionCall(tok, getIndirect(tok), getSettings(), &inconclusive)) |
| 226 | return Action::Read | Action::Invalid; |
| 227 | if (inconclusive) |
| 228 | return Action::Read | Action::Inconclusive; |
| 229 | if (isVariableChanged(tok, getIndirect(tok), getSettings())) { |
| 230 | if (Token::Match(tok->astParent(), "*|[|.|++|--")) |
| 231 | return Action::Read | Action::Invalid; |
| 232 | // Check if its assigned to the same value |
| 233 | if (value && !value->isImpossible() && Token::simpleMatch(tok->astParent(), "=") && astIsLHS(tok) && |
| 234 | astIsIntegral(tok->astParent()->astOperand2(), false)) { |
| 235 | std::vector<MathLib::bigint> result = evaluateInt(tok->astParent()->astOperand2()); |
| 236 | if (!result.empty() && value->equalTo(result.front())) |
| 237 | return Action::Idempotent; |
| 238 | } |
| 239 | return Action::Invalid; |
| 240 | } |
| 241 | return Action::Read; |
| 242 | } |
| 243 | |
| 244 | virtual Action isAliasModified(const Token* tok, int indirect = -1) const { |
| 245 | // Lambda function call |
no test coverage detected