[clang-tools-extra] Create a new check to look for mis-use in calls that take iterators (PR #99917)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 23 07:10:16 PDT 2024


================
@@ -0,0 +1,121 @@
+.. 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
----------------
EugeneZelenko wrote:

```suggestion
Looks for calls where the ``begin`` parameter is passed an ``end`` argument or vice
```

https://github.com/llvm/llvm-project/pull/99917


More information about the cfe-commits mailing list