[PATCH] D16962: clang-tidy: avoid std::bind

Jonathan B Coe via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 15 13:31:36 PDT 2016


jbcoe added inline comments.

================
Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:42
@@ +41,3 @@
+
+  for (size_t I = 1, ArgCount = C->getNumArgs(); I < ArgCount; ++I) {
+    const Expr *E = C->getArg(I);
----------------
alexfh wrote:
> Please use a range-based for loop over `C->arguments()`.
I'm starting at 1 not zero, hence the explicit loop.

Elements are non-contiguous so I can't use a restricted ArrayView.

I've added a comment saying why it starts at 1, not 0.

================
Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:127
@@ +126,3 @@
+  auto DiagnosticBuilder =
+      diag(MatchedDecl->getLocStart(), "avoid using std::bind");
+
----------------
alexfh wrote:
> alexfh wrote:
> > Should the message recommend something instead?
> In pre-C++11 code the check will just warn without suggesting any alternative. That will lead to a lot of user confusion. We either need to restrict the warning to C++14 code or suggest a better alternative even in pre-C++14 code.
The message now recommends using a lambda so I think this is addressed.


http://reviews.llvm.org/D16962





More information about the cfe-commits mailing list