[PATCH] D83188: [clang-tidy] bugprone-bool-pointer-implicit-conversion doesn't handle members

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 21 11:49:32 PDT 2020


aaron.ballman added a comment.

LGTM, though I have a possible code simplification if you think it's an improvement.



================
Comment at: clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp:78
+
+  if (const auto *DeclRef = Result.Nodes.getNodeAs<DeclRefExpr>("expr")) {
+    const Decl *D = DeclRef->getDecl();
----------------
Can you get away with:
```
if (const auto *E = Result.Nodes.getNodeAs<Expr>("expr")) {
  const Decl *D = isa<DeclRefExpr> ? cast<DeclRefExpr>(E)->getDecl() : cast<MemberExpr>(E)->getMemberDecl();
  const auto M = ignoringParenImpCasts(anyOf(declRefExpr(to(equalsNode(D))), memberExpr(hasDeclaration(equalsNode(D)))));
  checkImpl(Result, E, If, M, *this);
}
```
(Totally untested, but it hopefully demonstrates the point.)


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

https://reviews.llvm.org/D83188





More information about the cfe-commits mailing list