[PATCH] D52281: Use std::invoke in generic code

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 19 15:35:13 PDT 2018


Eugene.Zelenko added inline comments.


================
Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:1
+//===--- ReplaceGenericFunctorCallCheck.cpp - clang-tidy-------------------===//
+//
----------------
Please add space after clang-tidy.


================
Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:48
+    const MatchFinder::MatchResult &Result) {
+
+  const auto *Source = Result.SourceManager;
----------------
Please remove empty line.


================
Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:49
+
+  const auto *Source = Result.SourceManager;
+
----------------
Please don't use auto when type could not be deduced from same statement.


================
Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:53
+  if (Functor && Functor->isTypeDependent()) {
+    const auto EndLoc = Functor->getNumArgs() == 0
+                            ? Functor->getRParenLoc()
----------------
Please don't use auto when type could not be deduced from same statement.


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


================
Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:78
+
+    const auto *MFunc = BinOp->getRHS();
+    const char *MFuncEnd = Source->getCharacterData(Paren->getRParen());
----------------
Please don't use auto when type could not be deduced from same statement.


================
Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:96
+    const std::string &OriginalParams) {
+
+  std::ostringstream Replace;
----------------
Please remove empty line.


================
Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.h:1
+//===--- ReplaceGenericFunctorCallCheck.h - clang-tidy-----------*- C++ -*-===//
+//
----------------
Please add space after clang-tidy.


================
Comment at: docs/ReleaseNotes.rst:60
 
+- New `modernize-replace-generic-functor-call
+  <http://clang.llvm.org/extra/clang-tidy/checks/modernize-replace-generic-functor-call.html>`_ check
----------------
Please sort new checks list in alphabetical order.


================
Comment at: docs/ReleaseNotes.rst:63
+
+  Replace type dependent functor, function pointer and pointer to member call
+  to the proper ``std::invoke()`` in C++17 or newer codebases.
----------------
Replace -> Replaces.


================
Comment at: docs/clang-tidy/checks/modernize-replace-generic-functor-call.rst:6
+
+This check finds and replace the functor, function pointer and pointer to member
+calls to the proper ``std::invoke()`` call. It works only in C++17 or newer.
----------------
Please make first statement same as in Release Notes.


================
Comment at: docs/clang-tidy/checks/modernize-replace-generic-functor-call.rst:15
+  void f(T1 func, T2 mfp) {
+    func(2); // Replace to ::std::invoke(func, 2)
+    Foo foo;
----------------
Please use more descriptive identifiers and separate statements with empty lines. Same for other places.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52281





More information about the cfe-commits mailing list