| 488 | } |
| 489 | |
| 490 | static bool isDeadTemporary(const Token* tok, const Token* expr, const Library& library) |
| 491 | { |
| 492 | if (!isTemporary(tok, &library)) |
| 493 | return false; |
| 494 | if (expr) { |
| 495 | if (!precedes(nextAfterAstRightmostLeaf(tok->astTop()), nextAfterAstRightmostLeaf(expr->astTop()))) |
| 496 | return false; |
| 497 | const Token* parent = tok->astParent(); |
| 498 | if (Token::simpleMatch(parent, "{") && Token::simpleMatch(parent->astParent(), ":")) |
| 499 | parent = parent->astParent(); |
| 500 | // Is in a for loop |
| 501 | if (astIsRHS(tok) && Token::simpleMatch(parent, ":") && Token::simpleMatch(parent->astParent(), "(") && Token::simpleMatch(parent->astParent()->previous(), "for (")) { |
| 502 | const Token* braces = parent->astParent()->link()->next(); |
| 503 | if (precedes(braces, expr) && precedes(expr, braces->link())) |
| 504 | return false; |
| 505 | } |
| 506 | } |
| 507 | return true; |
| 508 | } |
| 509 | |
| 510 | static bool isEscapedReference(const Variable* var) |
| 511 | { |
no test coverage detected