[cfe-commits] r147258 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CodeGenCXX/virtual-implicit-move-assignment.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Sat Dec 24 13:56:24 PST 2011
Author: rsmith
Date: Sat Dec 24 15:56:24 2011
New Revision: 147258
URL: http://llvm.org/viewvc/llvm-project?rev=147258&view=rev
Log:
Always implicitly declare move assignment operations for dynamic classes, in
case they override virtual functions from a base class. Also fix -print-stats
counting of move assignment/construction.
Added:
cfe/trunk/test/CodeGenCXX/virtual-implicit-move-assignment.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=147258&r1=147257&r2=147258&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Dec 24 15:56:24 2011
@@ -4981,6 +4981,9 @@
if (!ClassDecl->hasUserDeclaredCopyConstructor())
++ASTContext::NumImplicitCopyConstructors;
+ if (getLangOptions().CPlusPlus0x && ClassDecl->needsImplicitMoveConstructor())
+ ++ASTContext::NumImplicitMoveConstructors;
+
if (!ClassDecl->hasUserDeclaredCopyAssignment()) {
++ASTContext::NumImplicitCopyAssignmentOperators;
@@ -4992,6 +4995,14 @@
DeclareImplicitCopyAssignment(ClassDecl);
}
+ if (getLangOptions().CPlusPlus0x && ClassDecl->needsImplicitMoveAssignment()){
+ ++ASTContext::NumImplicitMoveAssignmentOperators;
+
+ // Likewise for the move assignment operator.
+ if (ClassDecl->isDynamicClass())
+ DeclareImplicitMoveAssignment(ClassDecl);
+ }
+
if (!ClassDecl->hasUserDeclaredDestructor()) {
++ASTContext::NumImplicitDestructors;
Added: cfe/trunk/test/CodeGenCXX/virtual-implicit-move-assignment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-implicit-move-assignment.cpp?rev=147258&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/virtual-implicit-move-assignment.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/virtual-implicit-move-assignment.cpp Sat Dec 24 15:56:24 2011
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -std=c++11 -o - %s | FileCheck %s
+
+struct D;
+struct B {
+ virtual D &operator=(D&&) = 0;
+};
+struct D : B { D(); virtual void a(); };
+void D::a() {}
+D d;
+
+// CHECK: @_ZTV1D = {{.*}} @_ZN1DaSEOS_
+// CHECK: define linkonce_odr {{.*}} @_ZN1DaSEOS_
More information about the cfe-commits
mailing list