[clang] [LifetimeSafety] Track moved declarations to prevent false positives (PR #170007)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 16 10:27:02 PST 2026


================
@@ -1392,3 +1397,25 @@ void add(int c, MyObj* node) {
   arr[4] = node;
 }
 } // namespace CppCoverage
+
+namespace do_not_warn_on_std_move {
+void silenced() {
+  MyObj b;
+  View v;
+  {
+    MyObj a;
+    v = a;
+    b = std::move(a); // No warning for 'a' being moved.
+  }
+  (void)v;
+}
+
+void silenced_flow_insensitive(bool c) {
+  MyObj a;
+  View v = a;
+  if (c) {
+    MyObj b = std::move(a);
----------------
Xazax-hun wrote:

Should we have a test with a fixme for the `std::move(cond?a:b)` case?

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


More information about the cfe-commits mailing list