[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
Wed Feb 28 13:39:28 PST 2018
Quuxplusone added inline comments.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5639
+ "local variable %0 will be copied despite being %select{returned|thrown}1 by name">,
+ InGroup<ReturnStdMove>, DefaultIgnore;
+def note_add_std_move : Note<
----------------
I would like some guidance on whether it would be appropriate to turn this warning on as part of `-Wmove`.
================
Comment at: lib/Sema/SemaStmt.cpp:3083
+ Diag(Value->getExprLoc(), diag::warn_return_std_move_in_cxx11)
+ << Value->getSourceRange()
+ << NRVOCandidate->getDeclName() << ResultType << QT;
----------------
This source range does the right thing; thanks @rtrieu!
Repository:
rC Clang
https://reviews.llvm.org/D43322
More information about the cfe-commits
mailing list