================ @@ -0,0 +1,122 @@ +.. title:: clang-tidy - bugprone-incorrect-iterators + +bugprone-incorrect-iterators +============================ + +Detects calls to iterator algorithms where they are called with potentially +invalid arguments. + +Different ranges +================ + +Looks for calls where the range for the ``begin`` argument is different to the +``end`` argument. + +.. code-block:: c++ + + std::find(a.begin(), b.end(), 0); + std::find(std::begin(a), std::end(b)); + +Mismatched Begin/end +==================== + +Looks for calls where the ``begin`` parameter is passed an ``end`` argument or +vice versa. + +.. code-block:: c++ + + std::find(a.begin(), a.begin(), 0); // Second argument should be a.end(). + +Container Methods +================= + +Looks for calls to methods on containers that expect an iterator inside the +container but are given a different container. + +.. code-block:: c++ + + vec.insert(other.begin(), 5); // The iterator is invalid for this container. + std::find(a.end(), a.end(), 0); // First argument should be a.begin(). ---------------- 5chmidti wrote:
Isn't this an example of the `Mismatched Begin/End`? https://github.com/llvm/llvm-project/pull/99917 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits