diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-21 19:38:21 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-21 19:38:21 +0000 |
commit | cc15f010672a13b38104a32e3cefc7adc07ffbf7 (patch) | |
tree | 6d229587f576842290d3770ef4aa8518cd7b1abc /lib/Sema/SemaInit.cpp | |
parent | 4a46c77813af1241139b81a086b539e4d734cb86 (diff) |
Implement the preference for move-construction over copy-construction
when returning an NRVO candidate expression. For example, this
properly picks the move constructor when dealing with code such as
MoveOnlyType f() { MoveOnlyType mot; return mot; }
The previously-XFAIL'd rvalue-references test case now works, and has
been moved into the appropriate paragraph-specific test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 9e8a15739f..00a13b54cf 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -3363,20 +3363,20 @@ static ExprResult CopyObject(Sema &S, if (S.RequireCompleteType(Loc, T, S.PDiag(diag::err_temp_copy_incomplete))) return move(CurInit); - // Perform overload resolution using the class's copy constructors. + // Perform overload resolution using the class's copy/move constructors. DeclContext::lookup_iterator Con, ConEnd; OverloadCandidateSet CandidateSet(Loc); for (llvm::tie(Con, ConEnd) = S.LookupConstructors(Class); Con != ConEnd; ++Con) { - // Only consider copy constructors and constructor templates. Per + // Only consider copy/move constructors and constructor templates. Per // C++0x [dcl.init]p16, second bullet to class types, this // initialization is direct-initialization. CXXConstructorDecl *Constructor = 0; if ((Constructor = dyn_cast<CXXConstructorDecl>(*Con))) { - // Handle copy constructors, only. + // Handle copy/moveconstructors, only. if (!Constructor || Constructor->isInvalidDecl() || - !Constructor->isCopyConstructor() || + !Constructor->isCopyOrMoveConstructor() || !Constructor->isConvertingConstructor(/*AllowExplicit=*/true)) continue; |