| 3365 | } |
| 3366 | |
| 3367 | static bool checkVariableAssignment(const Token* tok, const ValueType* vtLhs, const Settings& settings) |
| 3368 | { |
| 3369 | if (!Token::Match(tok, "%var% ;")) |
| 3370 | return false; |
| 3371 | const Variable* var = tok->variable(); |
| 3372 | if (!var || !isLargeObject(var, settings)) |
| 3373 | return false; |
| 3374 | if (!vtLhs || !vtLhs->isTypeEqual(var->valueType())) |
| 3375 | return false; |
| 3376 | if (findVariableChanged(tok->tokAt(2), tok->scope()->bodyEnd, /*indirect*/ 0, var->declarationId(), /*globalvar*/ false, settings)) |
| 3377 | return false; |
| 3378 | if (var->isLocal() || (var->isArgument() && !var->isReference())) |
| 3379 | return true; |
| 3380 | const Scope* scope = tok->scope(); |
| 3381 | while (scope && scope->type != ScopeType::eFunction) |
| 3382 | scope = scope->nestedIn; |
| 3383 | return scope && scope->function && (!scope->functionOf || scope->function->isConst() || scope->function->isStatic()); |
| 3384 | } |
| 3385 | |
| 3386 | void CheckOtherImpl::checkRedundantCopy() |
| 3387 | { |
no test coverage detected