[PATCH] D54560: [analyzer] MoveChecker Pt.3: Improve warning messages a bit.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 16 16:26:22 PST 2018


NoQ added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:385-386
+  }
+  // Provide the caller with the classification of the object
+  // we've obtained here accidentally, for later use.
+  return OK;
----------------
Szelethus wrote:
> Maybe move this in-class?
Mmm, what do you mean?


================
Comment at: test/Analysis/use-after-move.cpp:789
     // in STL the object is left in "valid but unspecified state" after move.
-    std::vector<int> W = std::move(V); // expected-note{{'V' became 'moved-from' here}}
-    V.push_back(123); // expected-warning{{Method call on a 'moved-from' object 'V'}}
-                      // expected-note at -1{{Method call on a 'moved-from' object 'V'}}
+    std::vector<int> W = std::move(V); // expected-note{{Object 'V' of type 'std::vector' is left in valid but unspecified state after move}}
+    V.push_back(123); // expected-warning{{Method called on moved-from object 'V'}}
----------------
Note how when an object is both a local and an STL object, the bug is reported as an STL bug. Which is good because it's more dangerous to use an STL object after move than to use your average local variable after move.


https://reviews.llvm.org/D54560





More information about the cfe-commits mailing list