[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 15 11:41:49 PDT 2018


Quuxplusone added inline comments.


================
Comment at: include/clang/Basic/DiagnosticGroups.td:388
 def PessimizingMove : DiagGroup<"pessimizing-move">;
+def ReturnStdMoveInCXX11 : DiagGroup<"return-std-move-in-c++11">;
+def ReturnStdMove : DiagGroup<"return-std-move">;
----------------
>> The backward-compatibility-concerned diagnostic, -Wreturn-std-move-in-c++11, is *not* appropriate for -Wmove;
> Have you evaluated possibility of adding -Wreturn-std-move-in-c++11 to one of CXX..Compat groups?

Hmm. I've considered it, but I don't know what the appropriate action is...
I suspect that it should *not* be "CXX11Compat" because technically the change was a DR against C++11 — sadly this is about portability to "older" compilers, not portability to "lesser" C++ standards.
Of course it can't be "CXX98Compat", for several reasons. :)
I'm not sure of the purpose of the "CXX..CompatPedantic" groups. They are all identical to the "CXX..Compat" groups, except that CXX98CompatPedantic includes one extra warning about binding to lifetime-extended temporaries which don't have copy constructors.


Repository:
  rC Clang

https://reviews.llvm.org/D43322





More information about the cfe-commits mailing list