Adds support for recognising and converting boolean expressions that can be simplified using De Morgans Law.
This is a different implementation to D124650.
Paths
| Differential D124806
[clang-tidy] add support for Demorgan conversions to readability-simplify-bool-expr ClosedPublic Authored by njames93 on May 2 2022, 2:37 PM.
Details Summary Adds support for recognising and converting boolean expressions that can be simplified using De Morgans Law. This is a different implementation to D124650.
Diff Detail
Event TimelineComment Actions Add tracking info to prevented nested cases from emitting conflicting fixes, disabled for use cases like clangd. Comment Actions Enhanced support for parens, both adding them in when needed as well as removing some un-needed parens. Comment Actions Reimplement matchers as an ASTVisitor instead. This revision is now accepted and ready to land.May 18 2022, 11:15 AM Comment Actions
Cheers. Comment Actions Remove unnecessary parens in documentation as check will remove the parens when possible. Comment Actions
When I've brought it up in manual code reviews before, there were some objections.
The reason I proposed the simplification !(!A && B) -> A || !B is because the former employs In the case of !(A && B) -> !A || !B, no double negative is involved and one could argue Closed by commit rGaf77b1d99016: [clang-tidy] add support for Demorgan conversions to readability-simplify-bool… (authored by njames93). · Explain WhyMay 22 2022, 1:28 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 429907 clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-demorgan.cpp
|