| 435 | //--------------------------------------------------------------------------- |
| 436 | |
| 437 | static bool isInScope(const Token * tok, const Scope * scope) |
| 438 | { |
| 439 | if (!tok) |
| 440 | return false; |
| 441 | if (!scope) |
| 442 | return false; |
| 443 | const Variable * var = tok->variable(); |
| 444 | if (var && (var->isGlobal() || var->isStatic() || var->isExtern())) |
| 445 | return false; |
| 446 | if (tok->scope() && !tok->scope()->isClassOrStructOrUnion() && tok->scope()->isNestedIn(scope)) |
| 447 | return true; |
| 448 | if (!var) |
| 449 | return false; |
| 450 | if (var->isArgument() && !var->isReference()) { |
| 451 | const Scope * tokScope = tok->scope(); |
| 452 | if (!tokScope) |
| 453 | return false; |
| 454 | if (std::any_of(tokScope->nestedList.cbegin(), tokScope->nestedList.cend(), [&](const Scope* argScope) { |
| 455 | return argScope && argScope->isNestedIn(scope); |
| 456 | })) |
| 457 | return true; |
| 458 | } |
| 459 | return false; |
| 460 | } |
| 461 | |
| 462 | static bool isDeadScope(const Token * tok, const Scope * scope) |
| 463 | { |
no test coverage detected