[PATCH] D70368: [clang-tidy] Rewrite modernize-avoid-bind check

Zachary Turner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 18 15:13:55 PST 2019


zturner marked 2 inline comments as done.
zturner added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:116
+static const Expr *ignoreTemporariesAndImplicitCasts(const Expr *E) {
+  if (const auto *T = dyn_cast<MaterializeTemporaryExpr>(E))
+    return ignoreTemporariesAndImplicitCasts(T->GetTemporaryExpr());
----------------
aaron.ballman wrote:
> What about `CXXBindTemporaryExpr`?
> 
> Would `Expr::IgnoreImplicit()` do too much stripping because it removes `FullExpr` as well?
I don't actually know.  This patch is literally my first exposure to clang's frontend and AST manipulations, so I was kind of just trying different things until something worked here.  I didn't even know about `IgnoreImplicit()` or `FullExpr`.  I'll play around with them and report back.


================
Comment at: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:153
+
+  return HNM.matchesNode(*dyn_cast<NamedDecl>(D));
+}
----------------
aaron.ballman wrote:
> This should probably use `cast<>` if it's going to assume the returned value is never null.
Good point.  Since we're talking about this code anyway, it felt super hacky to instantiate an AST matcher just to check for the qualified name of a Decl.  Is there a better way to do this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70368





More information about the cfe-commits mailing list