[PATCH] D45163: [Sema] -Wunused-value: diagnose unused std::move() call results.

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 2 07:28:27 PDT 2018


lebedev.ri created this revision.
lebedev.ri added reviewers: aaron.ballman, rsmith, rtrieu, rjmccall, dblaikie.

I have seen such a problem when reviewing https://reviews.llvm.org/D43341.
https://godbolt.org/g/aJYcaa

  #include <utility>
  
  struct S {};
  
  void test(S a) {
      std::move(a);
  }

Since `std::move()` is not marked with `nodiscard` attribute in the standard
(should it be? how complicated would it be to write such a proposal?),
nothing diagnoses such code. But i really don't see why one would intentionally write that.
You have either forgot to assign/pass the result, or you wanted to cast to `void`.

Stage-2 self-hosting is green, no preparatory changes needed!


Repository:
  rC Clang

https://reviews.llvm.org/D45163

Files:
  docs/ReleaseNotes.rst
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Expr.cpp
  lib/Sema/SemaStmt.cpp
  test/Analysis/MisusedMovedObject.cpp
  test/SemaCXX/warn-unused-result-nodiscard.cpp
  test/SemaCXX/warn-unused-xvalue.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45163.140621.patch
Type: text/x-patch
Size: 9588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180402/5dd518d4/attachment-0001.bin>


More information about the cfe-commits mailing list