| 755 | } |
| 756 | |
| 757 | bool CheckStlImpl::checkIteratorPair(const Token* tok1, const Token* tok2) |
| 758 | { |
| 759 | if (!tok1) |
| 760 | return false; |
| 761 | if (!tok2) |
| 762 | return false; |
| 763 | ValueFlow::Value val1 = getLifetimeIteratorValue(tok1); |
| 764 | ValueFlow::Value val2 = getLifetimeIteratorValue(tok2); |
| 765 | if (val1.tokvalue && val2.tokvalue && val1.lifetimeKind == val2.lifetimeKind) { |
| 766 | if (val1.lifetimeKind == ValueFlow::Value::LifetimeKind::Lambda) |
| 767 | return false; |
| 768 | if (tok1->astParent() == tok2->astParent() && Token::Match(tok1->astParent(), "%comp%|-")) { |
| 769 | if (val1.lifetimeKind == ValueFlow::Value::LifetimeKind::Address) |
| 770 | return false; |
| 771 | if (val1.lifetimeKind == ValueFlow::Value::LifetimeKind::Object && |
| 772 | (!astIsContainer(val1.tokvalue) || !astIsContainer(val2.tokvalue))) |
| 773 | return false; |
| 774 | } |
| 775 | if (isSameIteratorContainerExpression(val1.tokvalue, val2.tokvalue, mSettings, val1.lifetimeKind)) |
| 776 | return false; |
| 777 | if (val1.tokvalue->expressionString() == val2.tokvalue->expressionString()) |
| 778 | iteratorsError(tok1, val1.tokvalue, val1.tokvalue->expressionString()); |
| 779 | else |
| 780 | mismatchingContainersError(val1.tokvalue, val2.tokvalue); |
| 781 | return true; |
| 782 | } |
| 783 | |
| 784 | if (Token::Match(tok1->astParent(), "%comp%|-")) { |
| 785 | if (astIsIntegral(tok1, true) || astIsIntegral(tok2, true) || |
| 786 | astIsFloat(tok1, true) || astIsFloat(tok2, true)) |
| 787 | return false; |
| 788 | } |
| 789 | const Token* iter1 = getIteratorExpression(tok1); |
| 790 | if (!iter1) |
| 791 | return false; |
| 792 | const Token* iter2 = getIteratorExpression(tok2); |
| 793 | if (!iter2) |
| 794 | return false; |
| 795 | if (!isSameIteratorContainerExpression(iter1, iter2, mSettings)) { |
| 796 | mismatchingContainerExpressionError(iter1, iter2); |
| 797 | return true; |
| 798 | } |
| 799 | return false; |
| 800 | } |
| 801 | |
| 802 | namespace { |
| 803 | struct ArgIteratorInfo { |
nothing calls this directly
no test coverage detected