| 692 | } |
| 693 | |
| 694 | static bool isSameIteratorContainerExpression(const Token* tok1, |
| 695 | const Token* tok2, |
| 696 | const Settings& settings, |
| 697 | ValueFlow::Value::LifetimeKind kind = ValueFlow::Value::LifetimeKind::Iterator) |
| 698 | { |
| 699 | if (isSameExpression(false, tok1, tok2, settings, false, false)) { |
| 700 | return !astIsContainerOwned(tok1) || !isTemporary(tok1, &settings.library); |
| 701 | } |
| 702 | if (astContainerYield(tok2, settings.library) == Library::Container::Yield::ITEM) |
| 703 | return true; |
| 704 | if (kind == ValueFlow::Value::LifetimeKind::Address || kind == ValueFlow::Value::LifetimeKind::Iterator) { |
| 705 | const auto address1 = getAddressContainer(tok1); |
| 706 | const auto address2 = getAddressContainer(tok2); |
| 707 | return std::any_of(address1.begin(), address1.end(), [&](const Token* tok1) { |
| 708 | return std::any_of(address2.begin(), address2.end(), [&](const Token* tok2) { |
| 709 | return isSameExpression(false, tok1, tok2, settings, false, false); |
| 710 | }); |
| 711 | }); |
| 712 | } |
| 713 | return false; |
| 714 | } |
| 715 | |
| 716 | // First it groups the lifetimes together using std::partition with the lifetimes that refer to the same token or token of a subexpression. |
| 717 | // Then it finds the lifetime in that group that refers to the "highest" parent using std::min_element and adds that to the vector. |
no test coverage detected