]> granicus.if.org Git - clang/commitdiff
Allow elision of invocations of move constructors from temporary objects.
authorDouglas Gregor <dgregor@apple.com>
Thu, 27 Jan 2011 23:24:55 +0000 (23:24 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 27 Jan 2011 23:24:55 +0000 (23:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124455 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CodeGenCXX/rvalue-references.cpp

index 78d9a5b959acc0f6ce2474ae53d32fec2dca3632..5da10352cc10b6fd07b80e4fc02a0c19265e3be5 100644 (file)
@@ -5551,7 +5551,7 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
   //       can be omitted by constructing the temporary object
   //       directly into the target of the omitted copy/move
   if (ConstructKind == CXXConstructExpr::CK_Complete &&
-      Constructor->isCopyConstructor() && ExprArgs.size() >= 1) {
+      Constructor->isCopyOrMoveConstructor() && ExprArgs.size() >= 1) {
     Expr *SubExpr = ((Expr **)ExprArgs.get())[0];
     Elidable = SubExpr->isTemporaryObject(Context, Constructor->getParent());
   }
index a7c74ae5c06d9e2e78891f950afbd78d0cb686b8..e15172355ebd19784822d731c370cac9015dbf51 100644 (file)
@@ -62,13 +62,10 @@ C test();
 // CHECK: define void @_Z15elide_copy_initv
 void elide_copy_init() {
   ok = false;
-  // FIXME: We're doing an extra move here, when we shouldn't be!
-  // CHECK: call void @_Z4testv(%class.C* sret %ref.tmp)
-  // CHECK: call void @_ZN1CC1EOS_(%class.C* %a, %class.C* %ref.tmp)
-  // CHECK: call void @_ZN1CD1Ev(%class.C* %ref.tmp)
+  // CHECK: call void @_Z4testv
   C a = test();
-  // CHECK: call void @_ZN1CD1Ev(%class.C* %a)
-  // CHECK: ret void
+  // CHECK-NEXT: call void @_ZN1CD1Ev
+  // CHECK-NEXT: ret void
 }
 
 // CHECK: define void @_Z16test_move_returnv