[coro]Pass rvalue reference for named local variable to return_value
authorBrian Gesiak <modocache@gmail.com>
Mon, 8 Oct 2018 03:08:39 +0000 (03:08 +0000)
committerBrian Gesiak <modocache@gmail.com>
Mon, 8 Oct 2018 03:08:39 +0000 (03:08 +0000)
commit0b5683001175f2e321c90f6608ade719c0a34fab
tree044e904420ae2741374f6e7625f23020935b2e25
parentc058a68784d25309f786a0f98f6af1c549126607
[coro]Pass rvalue reference for named local variable to return_value

Summary:
Addressing https://bugs.llvm.org/show_bug.cgi?id=37265.

Implements [class.copy]/33 of coroutines TS.

When the criteria for elision of a copy/move operation are met, but not
for an exception-declaration, and the object to be copied is designated by an
lvalue, or when the expression in a return or co_return statement is a
(possibly parenthesized) id-expression that names an object with automatic
storage duration declared in the body or parameter-declaration-clause of the
innermost enclosing function or lambda-expression, overload resolution to select
the constructor for the copy or the return_value overload to call is first
performed as if the object were designated by an rvalue.

Patch by Tanoy Sinha!

Reviewers: modocache, GorNishanov

Reviewed By: modocache, GorNishanov

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D51741

llvm-svn: 343949
clang/lib/Sema/SemaCoroutine.cpp
clang/test/SemaCXX/coroutine-rvo.cpp [new file with mode: 0644]