[PATCH] D47067: Update NRVO logic to support early return
Taiju Tsuiki via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 31 05:42:01 PDT 2018
tzik added a comment.
In https://reviews.llvm.org/D47067#1116733, @rsmith wrote:
> Slightly reduced testcase:
>
> template<typename T> T f(T u, bool b) {
> T t;
> if (b) return t;
> return u;
> }
> struct X { X(); X(const X&); ~X(); void *data; };
>
> template X f(X, bool);
>
>
> ... which compiles to:
>
> X f(X u, bool b) {
> X::X(&return-slot);
> if (b) return;
> X::X(&return-slot, u);
> X::~X(&return-slot);
> }
>
>
> ... due to `t` incorrectly being used as an NRVO variable.
Thanks for your investigation!
I thought that's covered by Scope::setNRVOCandidate with a null `Candidate`. As `t` is not marked as an NRVO variable before its instantiation. There's likely something I missed that turn the flag on while its instantiation.
Repository:
rC Clang
https://reviews.llvm.org/D47067
More information about the cfe-commits
mailing list