Index: test/Analysis/iterator-range.cpp =================================================================== --- test/Analysis/iterator-range.cpp +++ test/Analysis/iterator-range.cpp @@ -216,6 +216,11 @@ *first; // no-warning } +void bad_non_std_find(std::vector &V, int e) { + auto first = nonStdFind(V.begin(), V.end(), e); + *first; // expected-warning{{Iterator accessed outside of its range}} +} + void tricky(std::vector &V, int e) { const auto first = V.begin(); const auto comp1 = (first != V.end()), comp2 = (first == V.end()); Index: test/Analysis/mismatched-iterator.cpp =================================================================== --- test/Analysis/mismatched-iterator.cpp +++ test/Analysis/mismatched-iterator.cpp @@ -144,6 +144,19 @@ v1.insert(i, n); // expected-warning{{Container accessed using foreign iterator argument}} } +template +bool is_cend(Container cont, Iterator it) { + return it == cont.cend(); +} + +void good_empty(std::vector &v) { + is_cend(v, v.cbegin()); // no-warning +} + +void bad_empty(std::vector &v1, std::vector &v2) { + is_cend(v1, v2.cbegin()); // expected-warning@149{{Iterators of different containers used where the same container is expected}} +} + void good_move(std::vector &v1, std::vector &v2) { const auto i0 = ++v2.cbegin(); v1 = std::move(v2);