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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 2 09:28:38 PDT 2016


aaron.ballman added inline comments.


> UseTransparentFunctorsCheck.cpp:26
> +      unless(hasAnyTemplateArgument(refersToType(voidType()))),
> +      hasAnyName("::std::plus", "::std::minus", "::std::multiplies",
> +                 "::std::divides", "::std::modulus", "::std::negate",

Should we make this a configurable list that users can add to?

> UseTransparentFunctorsCheck.cpp:61
> +          Result.Nodes.getNodeAs<CXXConstructExpr>("FuncInst")) {
> +    diag(FuncInst->getLocStart(), "prefer transparent functors");
> +    return;

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)?

> UseTransparentFunctorsCheck.cpp:93
> +
> +  diag(ReportLoc, "prefer transparent functors")
> +      << FixItHint::CreateRemoval(FunctorTypeLoc.getArgLoc(0).getSourceRange());

This diagnostic could stand to be less terse as well, IMO. The fixit helps though.

> modernize-use-transparent-functors.rst:6
> +
> +Prefer transparent functors to non-transparent ones. Using transparent functors
> +the type does not need to be repeated. The code is easier to read, maintain and

Using transparent functors the -> When using transparent functors, the

Repository:
  rL LLVM

https://reviews.llvm.org/D24894





More information about the cfe-commits mailing list