[PATCH] D124650: [clang-tidy] Simplify boolean expressions by DeMorgan's theorem

Richard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 1 13:56:09 PDT 2022


LegalizeAdulthood marked an inline comment as done.
LegalizeAdulthood added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:598-599
+  auto UnlessNotLHS = unless(hasLHS(NotOp));
+  // match !(!a || b)
+  Finder->addMatcher(unaryOperator(Not, hasUnaryOperand(binaryOperator(
+                                            Or, UnlessNotRHS, NotLHS, RHS)))
----------------
njames93 wrote:
> Maybe I'm overthinking this, but how come you don't need the match on the ParenExpr?
> Is there some traversal mode?
How can you have a binaryOperator as the child of unaryOperator without parens?  The precedence doesn't allow it otherwise.


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

https://reviews.llvm.org/D124650



More information about the cfe-commits mailing list