================
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-use-after-move %t
+
+#include <utility>
+
+struct A {
+ int a;
+};
+
+struct B : A {
+ int b;
+ B(B&& other) :
+ A(std::move(other)),
+ b(std::move(other.b))
+ // CHECK-NOTES-NOT: [[@LINE-1]]:7: warning: 'other' used after it was
moved
+ {}
----------------
localspook wrote:
Can we add a test like:
```suggestion
int b;
void f();
B(B&& other) :
A(std::move(other)),
b(std::move(other.b))
// CHECK-NOTES-NOT: [[@LINE-1]]:7: warning: 'other' used after it was
moved
{
other.f();
// CHECK-NOTES: [[@LINE-1]]:11: warning: 'other' used after it was
moved
// CHECK-NOTES: [[@LINE-6]]:7: note: move occurred here
}
```
To constrast how accessing a derived member variable after moving the base is
okay, but calling a derived member function isn't.
https://github.com/llvm/llvm-project/pull/189638
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits