[clang-tools-extra] Draft: 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
Mon Jul 22 12:06:23 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff e77a01d79a48e15c94c89e4aa4bd27424a96b49b a8eb65dd46e9fff572963cc980bf5ea582085ef1 --extensions h,cpp -- clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.h clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-iterators.cpp clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
index 56429b9100..ea0d34d545 100644
--- a/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
@@ -193,17 +193,19 @@ static auto makeContainerInternalMatcher(std::vector<StringRef> ClassNames,
                                          unsigned InternalExpected,
                                          const FullState &State) {
   return cxxMemberCallExpr(
-      thisPointerType(cxxRecordDecl(hasAnyName(std::move(ClassNames)))),
-      callee(cxxMethodDecl(hasAnyName(std::move(ClassMethods)))),
-      on(expr().bind(Internal)),
-      hasArgument(
-          InternalExpected,
-          makeExprMatcher(
-              expr(unless(matchers::isStatementIdenticalToBoundNode(Internal)))
-                  .bind(InternalOther),
-              State.All, State.MakeReverseIterator, State.All,
-              ArgMismatchRevBind)
-              .bind(InternalArgument))).bind(Callee);
+             thisPointerType(cxxRecordDecl(hasAnyName(std::move(ClassNames)))),
+             callee(cxxMethodDecl(hasAnyName(std::move(ClassMethods)))),
+             on(expr().bind(Internal)),
+             hasArgument(
+                 InternalExpected,
+                 makeExprMatcher(
+                     expr(unless(matchers::isStatementIdenticalToBoundNode(
+                              Internal)))
+                         .bind(InternalOther),
+                     State.All, State.MakeReverseIterator, State.All,
+                     ArgMismatchRevBind)
+                     .bind(InternalArgument)))
+      .bind(Callee);
 }
 
 /// Full matcher for class methods that take a range with 2 arguments

``````````

</details>


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


More information about the cfe-commits mailing list