[PATCH] D52281: [clang-tidy] Add modernize check to use std::invoke in generic code

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 22 11:47:52 PDT 2018


JonasToth added inline comments.


================
Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:70
+  if (MFunctor && MFunctor->isTypeDependent()) {
+    const auto *Paren = static_cast<const ParenExpr *>(MFunctor->getCallee());
+    const auto *BinOp =
----------------
Eugene.Zelenko wrote:
> I think you should use LLVM's cast instead, but I'm not sure which one. Same for other places.
in this case i think `const auto *BinOp = dyn_cast<BinaryOperator>(Paren->getSubExpr());` would match.

As a safety measure adding a `assert(BinOp && "No Binary Operator as subexpression");` helps spotting bugs.


================
Comment at: test/clang-tidy/modernize-replace-generic-functor-call.cpp:24
+template <class T>
+void func2(T func) {
+  func(1);
----------------
Please add tests that include the usage of macros to do the function call.
In my opinions these should be excluded from the FIXITs and only the warning should be emitted.


https://reviews.llvm.org/D52281





More information about the cfe-commits mailing list