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

2016-11-16 Thread Gábor Horváth via cfe-commits
xazax.hun closed this revision.
xazax.hun marked 2 inline comments as done.
xazax.hun added a comment.

Thanks for the reviews, committed in https://reviews.llvm.org/rL287107 .


https://reviews.llvm.org/D24894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-11-15 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:89
+diag(FuncInst->getLocStart(), Message)
+<< (FuncClass->getName() + "<>").str();
+return;

xazax.hun wrote:
> aaron.ballman wrote:
> > Is the `.str()` required? (Same question applies below.)
> It does not compile without it. It looks like the << is not overloaded for 
> Twine.
I learn something new every day. ;-)



Comment at: docs/clang-tidy/checks/modernize-use-transparent-functors.rst:8
+functors, the type does not need to be repeated. The code is easier to read,
+maintain and less prone to errors. It not possible to introduce unwanted
+conversions.

It not possible -> It is not possible



Comment at: docs/clang-tidy/checks/modernize-use-transparent-functors.rst:35-37
+   If the option is set to non-zero (default is `0`), the check will not
+   warn on these cases as shown above, where automatic FIXIT is not safe to
+   apply.

The way I read this, it seems to be claiming that if you set `SafeMode` to 
nonzero, the check never warns. How about:
```
   If the option is set to non-zero, the check will not diagnose cases where 
using a transparent functor cannot be guaranteed to produce identical results 
as the original code. The default value for this option is `0`.
```


https://reviews.llvm.org/D24894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-11-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:71
+
+static const StringRef Message = "prefer transparent functors (%0)";
+

You should quote the %0 to clarify that you're referring to syntax.



Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:89
+diag(FuncInst->getLocStart(), Message)
+<< (FuncClass->getName() + "<>").str();
+return;

Is the `.str()` required? (Same question applies below.)


https://reviews.llvm.org/D24894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-11-03 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 76860.
xazax.hun marked 5 inline comments as done.
xazax.hun added a comment.

- Addressed review comments.


https://reviews.llvm.org/D24894

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
  clang-tidy/modernize/UseTransparentFunctorsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-transparent-functors.rst
  test/clang-tidy/modernize-use-transparent-functors.cpp

Index: test/clang-tidy/modernize-use-transparent-functors.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-transparent-functors.cpp
@@ -0,0 +1,107 @@
+// RUN: %check_clang_tidy %s modernize-use-transparent-functors %t -- -- -std=c++14
+
+namespace std {
+template
+struct remove_reference;
+
+template 
+constexpr T &(typename std::remove_reference::type );
+
+template 
+constexpr T &(typename std::remove_reference::type &);
+
+template 
+struct plus {
+  constexpr T operator()(const T , const T ) const;
+};
+
+template <>
+struct plus {
+  template 
+  constexpr auto operator()(T &, U &) const -> 
+decltype(forward(Lhs) + forward(Rhs));
+};
+
+template 
+struct less {
+  constexpr bool operator()(const T , const T ) const;
+};
+
+template <>
+struct less {
+  template 
+  constexpr bool operator()(T &, U &) const;
+};
+
+template 
+struct logical_not {
+  constexpr bool operator()(const T ) const;
+};
+
+template <>
+struct logical_not {
+  template 
+  constexpr bool operator()(T &) const;
+};
+
+template 
+class allocator;
+
+template <
+class Key,
+class Compare = std::less<>,
+class Allocator = std::allocator>
+class set {};
+
+template <
+class Key,
+class Compare = std::less,
+class Allocator = std::allocator>
+class set2 {};
+
+template 
+InputIt find_if(InputIt first, InputIt last,
+UnaryPredicate p);
+
+template 
+void sort(RandomIt first, RandomIt last, Compare comp);
+
+class iterator {};
+class string {};
+}
+
+int main() {
+  using std::set;
+  using std::less;
+  std::set s;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer transparent functors (less<>) [modernize-use-transparent-functors]
+  // CHECK-FIXES: {{^}}  std::set> s;{{$}}
+  set s2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  set> s2;{{$}}
+  set s3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  set> s3;{{$}}
+  std::set> s4;
+  std::set> s5;
+  std::set, std::less<>> s6;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  std::set>, std::less<>> s6;{{$}}
+  std::iterator begin, end;
+  sort(begin, end, std::less());
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: prefer transparent functors
+  std::sort(begin, end, std::less<>());
+  find_if(begin, end, std::logical_not());
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
+  std::find_if(begin, end, std::logical_not<>());
+  using my_set = std::set;
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  using my_set = std::set>;{{$}}
+  using my_set2 = std::set;
+  using my_less = std::less;
+  find_if(begin, end, my_less());
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
+  std::set2 control;
+}
+
+
Index: docs/clang-tidy/checks/modernize-use-transparent-functors.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-transparent-functors.rst
@@ -0,0 +1,39 @@
+.. title:: clang-tidy - modernize-use-transparent-functors
+
+modernize-use-transparent-functors
+==
+
+Prefer transparent functors to non-transparent ones. When using transparent
+functors, the type does not need to be repeated. The code is easier to read,
+maintain and less prone to errors. It not possible to introduce unwanted
+conversions.
+
+  .. code-block:: c++
+
+// Non-transparent functor  
+std::map s;
+
+// Transparent functor.
+std::map> s;
+
+// Non-transparent functor
+using MyFunctor = std::less;
+
+It is not always a safe transformation though. The following case will be 
+untouched to preserve the semantics.
+
+  .. code-block:: c++
+
+// Non-transparent functor  
+std::map> s;
+
+Options
+---
+
+.. option:: SafeMode
+
+   If the option is set to non-zero (default is `0`), the check will not
+   warn on these cases as shown above, where automatic FIXIT is not safe to
+   apply.
+
+This check 

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

2016-10-26 Thread Aaron Ballman via cfe-commits
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("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



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-10-23 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.



Comment at: docs/clang-tidy/checks/modernize-use-transparent-functors.rst:12
+  .. code-block:: c++
+
+// Non-transparent functor  

Say somewhere that you also handle cases like
std::less(arg1, arg2)
because from this documentation I didn't know about it.


https://reviews.llvm.org/D24894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-10-23 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.



Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:70
+static const StringRef Message =
+"prefer transparent functors (aka diamond operators)";
+

The message would be much better if you would put the name of this functor, like
"prefer transparent functor (%0)" where %0 would be evaluated to 
'std::greater<>" etc.



Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:89-109
+  for (; ArgNum < FunctorParentLoc.getNumArgs(); ++ArgNum) {
+const TemplateArgument  =
+FunctorParentLoc.getArgLoc(ArgNum).getArgument();
+if (Arg.getKind() != TemplateArgument::Type)
+  continue;
+QualType ParentArgType = Arg.getAsType();
+if (ParentArgType->isRecordType() &&

This can be moved to one or 2 functions, returning FunctorTypeLoc or 
llvm::Optional



Comment at: docs/clang-tidy/checks/modernize-use-transparent-functors.rst:32-33
+
+   If the option is set to non-zero (default is `0`), the check will not
+   warn on those cases where automatic FIXIT is not safe to apply.

I think
... will not warn on these cases as shown above, where automatic FIXIT...
would have been better.



Comment at: docs/clang-tidy/checks/modernize-use-transparent-functors.rst:33
+   If the option is set to non-zero (default is `0`), the check will not
+   warn on those cases where automatic FIXIT is not safe to apply.

Add a note
This check requires C++14 or higher to run.


https://reviews.llvm.org/D24894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-10-22 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

I have attached the results of this checker after running it on LLVM.

F2522345: results.txt 


https://reviews.llvm.org/D24894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-10-22 Thread Gábor Horváth via cfe-commits
xazax.hun updated the summary for this revision.
xazax.hun removed rL LLVM as the repository for this revision.
xazax.hun updated this revision to Diff 75530.
xazax.hun marked 3 inline comments as done.
xazax.hun added a comment.

- Fixed the performance problems.
- Altered the diagnostic text.
- Documentation improvements.
- Added an option to silence some warnings.
- Updated to latest trunk.


https://reviews.llvm.org/D24894

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
  clang-tidy/modernize/UseTransparentFunctorsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-transparent-functors.rst
  test/clang-tidy/modernize-use-transparent-functors.cpp

Index: test/clang-tidy/modernize-use-transparent-functors.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-transparent-functors.cpp
@@ -0,0 +1,107 @@
+// RUN: %check_clang_tidy %s modernize-use-transparent-functors %t -- -- -std=c++14
+
+namespace std {
+template
+struct remove_reference;
+
+template 
+constexpr T &(typename std::remove_reference::type );
+
+template 
+constexpr T &(typename std::remove_reference::type &);
+
+template 
+struct plus {
+  constexpr T operator()(const T , const T ) const;
+};
+
+template <>
+struct plus {
+  template 
+  constexpr auto operator()(T &, U &) const -> 
+decltype(forward(Lhs) + forward(Rhs));
+};
+
+template 
+struct less {
+  constexpr bool operator()(const T , const T ) const;
+};
+
+template <>
+struct less {
+  template 
+  constexpr bool operator()(T &, U &) const;
+};
+
+template 
+struct logical_not {
+  constexpr bool operator()(const T ) const;
+};
+
+template <>
+struct logical_not {
+  template 
+  constexpr bool operator()(T &) const;
+};
+
+template 
+class allocator;
+
+template <
+class Key,
+class Compare = std::less<>,
+class Allocator = std::allocator>
+class set {};
+
+template <
+class Key,
+class Compare = std::less,
+class Allocator = std::allocator>
+class set2 {};
+
+template 
+InputIt find_if(InputIt first, InputIt last,
+UnaryPredicate p);
+
+template 
+void sort(RandomIt first, RandomIt last, Compare comp);
+
+class iterator {};
+class string {};
+}
+
+int main() {
+  using std::set;
+  using std::less;
+  std::set s;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer transparent functors (aka diamond operators) [modernize-use-transparent-functors]
+  // CHECK-FIXES: {{^}}  std::set> s;{{$}}
+  set s2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  set> s2;{{$}}
+  set s3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  set> s3;{{$}}
+  std::set> s4;
+  std::set> s5;
+  std::set, std::less<>> s6;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  std::set>, std::less<>> s6;{{$}}
+  std::iterator begin, end;
+  sort(begin, end, std::less());
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: prefer transparent functors
+  std::sort(begin, end, std::less<>());
+  find_if(begin, end, std::logical_not());
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
+  std::find_if(begin, end, std::logical_not<>());
+  using my_set = std::set;
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  using my_set = std::set>;{{$}}
+  using my_set2 = std::set;
+  using my_less = std::less;
+  find_if(begin, end, my_less());
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
+  std::set2 control;
+}
+
+
Index: docs/clang-tidy/checks/modernize-use-transparent-functors.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-transparent-functors.rst
@@ -0,0 +1,33 @@
+.. title:: clang-tidy - modernize-use-transparent-functors
+
+modernize-use-transparent-functors
+==
+
+Prefer transparent functors to non-transparent ones. When using transparent
+functors, the type does not need to be repeated. The code is easier to read,
+maintain and less prone to errors. It not possible to introduce unwanted
+conversions.
+
+  .. code-block:: c++
+
+// Non-transparent functor  
+std::map s;
+
+// Transparent functor.
+std::map> s;
+
+It is not always a safe transformation though. The following case will be 
+untouched to preserve the semantics.
+
+  .. code-block:: c++
+
+// Non-transparent functor  
+std::map> s;
+
+Options
+---
+
+.. 

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

2016-10-22 Thread Gábor Horváth via cfe-commits
xazax.hun 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",

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.



Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:61
+  Result.Nodes.getNodeAs("FuncInst")) {
+diag(FuncInst->getLocStart(), "prefer transparent functors");
+return;

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?


https://reviews.llvm.org/D24894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-10-02 Thread Aaron Ballman via cfe-commits
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("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



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-09-24 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: alexfh, hokein.
xazax.hun added a subscriber: cfe-commits.
xazax.hun set the repository for this revision to rL LLVM.
xazax.hun added a project: clang-tools-extra.
Herald added subscribers: mgorny, beanz.

This check finds the usages of non-transparent functors and suggest to use the 
transparent ones.

This check seems to be surprisingly slow though. Maybe because the amount of 
typelocs in the source code? I did not have a chance to do a profiling yet, but 
plan to do it later. Feel free to postpone the review until the profiling is 
done.

Repository:
  rL LLVM

https://reviews.llvm.org/D24894

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
  clang-tidy/modernize/UseTransparentFunctorsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-transparent-functors.rst
  test/clang-tidy/modernize-use-transparent-functors.cpp

Index: test/clang-tidy/modernize-use-transparent-functors.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-transparent-functors.cpp
@@ -0,0 +1,100 @@
+// RUN: %check_clang_tidy %s modernize-use-transparent-functors %t -- -- -std=c++14
+
+namespace std {
+template
+struct remove_reference;
+
+template 
+constexpr T &(typename std::remove_reference::type );
+
+template 
+constexpr T &(typename std::remove_reference::type &);
+
+template 
+struct plus {
+  constexpr T operator()(const T , const T ) const;
+};
+
+template <>
+struct plus {
+  template 
+  constexpr auto operator()(T &, U &) const -> 
+decltype(forward(Lhs) + forward(Rhs));
+};
+
+template 
+struct less {
+  constexpr bool operator()(const T , const T ) const;
+};
+
+template <>
+struct less {
+  template 
+  constexpr bool operator()(T &, U &) const;
+};
+
+template 
+struct logical_not {
+  constexpr bool operator()(const T ) const;
+};
+
+template <>
+struct logical_not {
+  template 
+  constexpr bool operator()(T &) const;
+};
+
+template 
+class allocator;
+
+template <
+class Key,
+class Compare = std::less<>,
+class Allocator = std::allocator>
+class set {};
+
+template 
+InputIt find_if(InputIt first, InputIt last,
+UnaryPredicate p);
+
+template 
+void sort(RandomIt first, RandomIt last, Compare comp);
+
+class iterator {};
+class string {};
+}
+
+int main() {
+  using std::set;
+  using std::less;
+  std::set s;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer transparent functors [modernize-use-transparent-functors]
+  // CHECK-FIXES: {{^}}  std::set> s;{{$}}
+  set s2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  set> s2;{{$}}
+  set s3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  set> s3;{{$}}
+  std::set> s4;
+  std::set> s5;
+  std::set, std::less<>> s6;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  std::set>, std::less<>> s6;{{$}}
+  std::iterator begin, end;
+  sort(begin, end, std::less());
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: prefer transparent functors
+  std::sort(begin, end, std::less<>());
+  find_if(begin, end, std::logical_not());
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
+  std::find_if(begin, end, std::logical_not<>());
+  using my_set = std::set;
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  using my_set = std::set>;{{$}}
+  using my_set2 = std::set;
+  using my_less = std::less;
+  find_if(begin, end, my_less());
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
+}
+
+
Index: docs/clang-tidy/checks/modernize-use-transparent-functors.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-transparent-functors.rst
@@ -0,0 +1,24 @@
+.. title:: clang-tidy - modernize-use-transparent-functors
+
+modernize-use-transparent-functors
+==
+
+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
+less prone to errors. It not possible to introduce unwanted conversions.
+
+  .. code-block:: c++
+
+// Non-transparent functor  
+std::map s;
+
+// Transparent functor.
+std::map> s;
+
+It is not always a safe transformation though. The following case will be 
+untouched to preserve the semantics.
+
+  .. code-block:: c++
+
+//