[PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'

Matt Kulukundis via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 10 09:09:13 PDT 2016


fowles added a subscriber: fowles.

================
Comment at: test/clang-tidy/misc-use-after-move.cpp:158
@@ +157,3 @@
+    std::move(ptr);
+    ptr.get();
+  }
----------------
would this warn on:

std::unique_ptr<A> ptr;
std::move(ptr);
ptr->Foo();

I would like it to since that is a likely segfault.

================
Comment at: test/clang-tidy/misc-use-after-move.cpp:279
@@ +278,3 @@
+    A a;
+    auto lambda = [=]() { a.foo(); };
+    std::move(a);
----------------
can you add tests with reference capture?

also what about:

A a;
auto lambda = [&]() { a.foo(); };
std::move(a);
lambda();


https://reviews.llvm.org/D23353





More information about the cfe-commits mailing list