[PATCH] D47122: [clang-tidy] SimplifyBoolenExpr doesn't add parens if unary negotiation is of ExprWithCleanups type
Malcolm Parsons via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 23 12:51:03 PDT 2018
malcolm.parsons added inline comments.
================
Comment at: clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:198
E = E->ignoreParenBaseCasts();
+ if (const auto *EC = dyn_cast<ExprWithCleanups>(E))
+ E = EC->getSubExpr();
----------------
zinovy.nis wrote:
> zinovy.nis wrote:
> > malcolm.parsons wrote:
> > > `E->IgnoreImplicit()` can be used to ignore `ExprWithCleanups`
> > Thanks. But it seems to be too agressive:
> >
> >
> > ```
> > return (i & 1) != 0;
> > ```
> >
> > becomes
> >
> > ```
> > return static_cast<bool>(i & 1);
> > ```
> >
> ```
> if (!isa<ImplicitCastExpr>(E))
> E = E->IgnoreImplicit();
>
> ```
>
> works properly but looks a bit verbose. What do you think?
I think what you've committed is fine.
Repository:
rL LLVM
https://reviews.llvm.org/D47122
More information about the cfe-commits
mailing list