[PATCH] Add readability-simplify-boolean-expr check to clang-tidy

Samuel Benzaquen sbenza at google.com
Tue Mar 3 10:39:52 PST 2015


================
Comment at: clang-tidy/readability/SimplifyBooleanExpr.cpp:62
@@ +61,3 @@
+
+internal::VariadicOperatorMatcher<internal::BindableMatcher<Stmt> &,
+                                  internal::BindableMatcher<Stmt>>
----------------
This type is an implementation detail.
Why not simply internal::Matcher<Stmt> ?

================
Comment at: clang-tidy/readability/SimplifyBooleanExpr.cpp:236
@@ +235,3 @@
+
+void SimplifyBooleanExpr::replaceWithLeftBooleanLiteral(
+    const MatchFinder::MatchResult &Result,
----------------
LegalizeAdulthood wrote:
> alexfh wrote:
> > Any luck replacing `replaceWith*` methods with a single one as Samuel suggested?
> I haven't done the experimenting yet, but I'm not hopeful.  They really are all just different enough that I haven't yet seen a way to unify them.
I'm sorry, but I have not seen one example that is really different.
They all do the same:

```
  diag(<SomeLocationInTheExpression>, SimplifyOperatorDiagnostic)
      << FixItHint::CreateReplacement(
             <TheRangeOfTheFullExpression>,
             <OptionalPrefix> + getText(Result, <TheSubExpressionWeSelectedAsReplacement>));
```
I posted code on how to do this generically for all (most?) the cases. It does not hard code binary operations or anything else. Only 3 things are needed here and the matcher can bind to generic ids.

http://reviews.llvm.org/D7648

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list