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

Devin Coughlin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 29 10:24:16 PST 2018


dcoughlin added a comment.

Looks good! Some suggested minor tweaks to diagnostic text inline.



================
Comment at: test/Analysis/use-after-move.cpp:146
+    A b = std::move(a); // expected-note {{Object 'a' is moved}}
+    b = a;              // expected-warning {{Moved-from object is copied 'a'}} expected-note {{Moved-from object is copied 'a'}}
   }
----------------
"Moved-from object is copied 'a'" doesn't read quite right. I think the object name is in the wrong spot. Instead, I would suggest: "Moved-from object 'a' is copied"


================
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'}}
----------------
NoQ wrote:
> 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.
I think the diagnostic text is missing an "a". It should be "... left in a valid but ... "


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54560/new/

https://reviews.llvm.org/D54560





More information about the cfe-commits mailing list