[PATCH] D24894: [clang-tidy] Prefer transparent functors to non-transparent one.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 11:56:20 PDT 2016


aaron.ballman added inline comments.


================
Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:26
+      unless(hasAnyTemplateArgument(refersToType(voidType()))),
+      hasAnyName("::std::plus", "::std::minus", "::std::multiplies",
+                 "::std::divides", "::std::modulus", "::std::negate",
----------------
xazax.hun wrote:
> aaron.ballman wrote:
> > Should we make this a configurable list that users can add to?
> I am not sure how frequent is that somebody would like to add some types to this list, but it can be added in a follow up patch.
I'm fine with a follow-on patch.


================
Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:61
+          Result.Nodes.getNodeAs<CXXConstructExpr>("FuncInst")) {
+    diag(FuncInst->getLocStart(), "prefer transparent functors");
+    return;
----------------
xazax.hun wrote:
> aaron.ballman wrote:
> > This diagnostic is too terse; anyone that is unaware of what a transparent functor is will likely be stumped by it, especially since there is no fixit.
> > 
> > Since this is the case where we cannot be sure that a transparent functor is the correct solution, should this be enabled via an option (default on)?
> I also extended the error message to refer to the alternative name (diamond operators) as well. 
> 
> I did add an option but I am not happy with the name of the option. Do you have a suggestion?
`SafeMode` is a bit dramatic-sounding, but I can't come up with something better, so it's probably fine.


https://reviews.llvm.org/D24894





More information about the cfe-commits mailing list