[PATCH] D21619: [Sema] Implement C++14's DR1579: Prefer moving id-expression out of functions

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 22 13:23:17 PDT 2016

erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, faisalv.
erik.pilkington added a subscriber: cfe-commits.

DR1579 says that when returning a id-expression from a function, we should attempt to return said expression by move first, then fallback to copy.

This patch does this by generalizing `PerformMoveOrCopyElision`, which previously did this when returning a id-expression that was a parameter.

This patch allows the following code to compile, for example:
struct Base {};
struct Derived : public Base {};
std::unique_ptr<Base> f() {
  std::unique_ptr<Derived> d;
  return d;
The DR in question: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579
Pointed out by PR27785.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21619.61589.patch
Type: text/x-patch
Size: 12145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160622/ea335e70/attachment.bin>

More information about the cfe-commits mailing list