[clang-tools-extra] [clang-tidy] Fix some false positive in bugprone-move-forwarding-reference (PR #191435)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 25 23:59:49 PDT 2026


================
@@ -111,3 +111,25 @@ template <typename T> void f12() {
   // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: forwarding reference passed to
   // CHECK-FIXES: [] (auto&& x) { T SomeT(std::forward<decltype(x)>(x)); };
 }
+
+// Ignore the case of captured variables where an implicit copy already
+// happened. Explicit capture version.
+template <typename T, typename U> void f13(U&& SomeU) {
+  [SomeU] () { T SomeT(std::move(SomeU)); };
+}
+
+// Ignore the case of captured variables where an implicit copy already
+// happened. Implicit capture version.
+template <typename T, typename U> void f14(U&& SomeU) {
+  [=] () { T SomeT(std::move(SomeU)); };
+}
+
+// Ignore the case of captured variables by reference. Explicit capture version.
+template <typename T, typename U> void f15(U&& SomeU) {
----------------
zeyi2 wrote:

IMO this looks like a false negative (those cases capture the forwarding reference by reference, so `std::move` still seems worth diagnosing).

While this is not a blocker from my side, it would be nice if we can add a `// FIXME` or `// TODO` comment.

https://github.com/llvm/llvm-project/pull/191435


More information about the cfe-commits mailing list