[PATCH] D94131: [clang-tidy] Use new mapAnyOf matcher

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 16 13:27:39 PST 2021


njames93 requested changes to this revision.
njames93 added a comment.
This revision now requires changes to proceed.

Can you either update the description of this patch to include the binaryOperation changes, or remove those changes from here.



================
Comment at: clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp:62
     Finder->addMatcher(
-        ifStmt(
-
-            allOf(hasWaitDescendantCPP,
-                  unless(anyOf(hasDescendant(ifStmt(hasWaitDescendantCPP)),
-                               hasDescendant(whileStmt(hasWaitDescendantCPP)),
-                               hasDescendant(forStmt(hasWaitDescendantCPP)),
-                               hasDescendant(doStmt(hasWaitDescendantCPP)))))
-
-                ),
+        ifStmt(allOf(
+            hasWaitDescendantCPP,
----------------
While were here, this allOf matcher could be removed.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp:43-45
+  const auto HasNoSelfCheck = cxxMethodDecl(unless(hasDescendant(
+      binaryOperation(hasAnyOperatorName("==", "!="),
+                      hasEitherOperand(ignoringParenCasts(cxxThisExpr()))))));
----------------
nit: Can this unrelated change be removed from this patch.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp:313
                // may be instantiated to use std::move() on built-in types.
-               binaryOperator(hasOperatorName("="), hasLHS(DeclRefMatcher)),
-               cxxOperatorCallExpr(hasOverloadedOperatorName("="),
-                                   hasArgument(0, DeclRefMatcher)),
+               binaryOperation(hasOperatorName("="), hasLHS(DeclRefMatcher)),
                // Declaration. We treat this as a type of reinitialization too,
----------------
nit: ditto.


================
Comment at: clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp:33-34
   const auto IsSourceMutatingAssignment = traverse(
-      TK_AsIs,
-      expr(anyOf(binaryOperator(isAssignmentOperator(), hasLHS(IsPartOfSource))
-                     .bind(MutatingOperatorName),
-                 cxxOperatorCallExpr(isAssignmentOperator(),
-                                     hasArgument(0, IsPartOfSource))
-                     .bind(MutatingOperatorName))));
+      TK_AsIs, binaryOperation(hasOperatorName("="), hasLHS(IsPartOfSource))
+                   .bind(MutatingOperatorName));
 
----------------
And here.


================
Comment at: clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp:42
   const auto IsSelfMutatingAssignment =
-      expr(anyOf(binaryOperator(isAssignmentOperator(), hasLHS(IsPartOfSelf)),
-                 cxxOperatorCallExpr(isAssignmentOperator(),
-                                     hasArgument(0, IsPartOfSelf))));
+      binaryOperation(isAssignmentOperator(), hasLHS(IsPartOfSelf));
 
----------------
Here.


================
Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp:213-215
+             hasCondition(ignoringImplicit(binaryOperation(
+                 hasOperatorName("!="), hasOperands(IteratorComparisonMatcher,
+                                                    IteratorBoundMatcher)))),
----------------
Also unrelated.


================
Comment at: clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp:186-188
+    if (match(traverse(TK_AsIs,
+                       compoundStmt(has(ignoringParenImpCasts(binaryOperation(
+                           hasOperatorName("="), hasLHS(LHS), hasRHS(RHS)))))),
----------------
Also unrelated.


================
Comment at: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:51-54
+      callOrConstruct(forEachArgumentWithParam(
+                          MoveCallMatcher,
+                          parmVarDecl(hasType(references(isConstQualified())))))
+          .bind("receiving-expr"),
----------------
Unrelated changes again.


================
Comment at: clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp:75
                      cxxUnresolvedConstructExpr(hasType(booleanType())),
-                     callExpr(hasAnyArgumentWithParam(
+                     callOrConstruct(hasAnyArgumentWithParam(
                          expr(equalsBoundNode(ExprName)),
----------------
Unrelated change.


================
Comment at: clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp:181-186
+      binaryOperation(unless(isInTemplateInstantiation()),
+                      hasAnyOperatorName("==", "!="),
+                      hasOperands(ignoringParenImpCasts(WrongComparend),
+                                  ignoringParenImpCasts(STLArg)),
+                      unless(hasAncestor(cxxMethodDecl(
+                          ofClass(equalsBoundNode("container"))))))
----------------
Unrelated change


================
Comment at: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp:70
   Matches =
-      match(findAll(cxxConstructExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
+      match(findAll(callOrConstruct(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
----------------
Unrelated change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94131/new/

https://reviews.llvm.org/D94131



More information about the cfe-commits mailing list