[PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

Samuel Benzaquen via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 10 07:19:23 PDT 2016


sbenza added inline comments.

================
Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:64
@@ +63,3 @@
+void MoveForwardingReferenceCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11)
+    return;
----------------
I'm guessing this is checking Lang==C++11, but we actually want Lang>=C++11, right?
I'm not sure if there is a way to check that.

================
Comment at: test/clang-tidy/misc-move-forwarding-reference.cpp:49
@@ +48,3 @@
+// Create a correct fix if there are spaces around the overload resolution
+// operator.
+template <typename T, typename U> void f5(U &&SomeU) {
----------------
I don't understand what this is trying to test.
What is the overload resolution operator?
Also, these two cases look exactly the same as the previous two.

================
Comment at: test/clang-tidy/misc-move-forwarding-reference.cpp:117
@@ +116,2 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
----------------
This is missing one case for C++14's generic lambdas.

```
[&] (auto&& x) { y = std::move(x); }

```
It might already detect correctly, but it will need a special case for generating the `std::forward`
It might need to be something like:

```
[&] (auto&& x) { y = std::forward<decltype(x)>(x); }

```
We can also just leave a TODO for later.


https://reviews.llvm.org/D22220





More information about the cfe-commits mailing list