aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-12-24 21:56:24 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-12-24 21:56:24 +0000
commitb701d3d0b20b00cb3b1d874a23f1e8d450f989f8 (patch)
treecf5644c17dccf15f6a37c99e92a9c96ad68e8df8
parent5cbd751a2f9d73248c5336140d73680fcd4669a3 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147258 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclCXX.cpp11
-rw-r--r--test/CodeGenCXX/virtual-implicit-move-assignment.cpp12
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 7f743f50f3..ad327ac755 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -4981,6 +4981,9 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
if (!ClassDecl->hasUserDeclaredCopyConstructor())
++ASTContext::NumImplicitCopyConstructors;
+ if (getLangOptions().CPlusPlus0x && ClassDecl->needsImplicitMoveConstructor())
+ ++ASTContext::NumImplicitMoveConstructors;
+
if (!ClassDecl->hasUserDeclaredCopyAssignment()) {
++ASTContext::NumImplicitCopyAssignmentOperators;
@@ -4992,6 +4995,14 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
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;
diff --git a/test/CodeGenCXX/virtual-implicit-move-assignment.cpp b/test/CodeGenCXX/virtual-implicit-move-assignment.cpp
new file mode 100644
index 0000000000..d8ac1ed4c4
--- /dev/null
+++ b/test/CodeGenCXX/virtual-implicit-move-assignment.cpp
@@ -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_