]> granicus.if.org Git - clang/commitdiff
Recognize simple cases of trivial explicitly defaulted public dtors as irrelevant
authorStephan Tolksdorf <st@quanttec.com>
Thu, 27 Mar 2014 20:23:12 +0000 (20:23 +0000)
committerStephan Tolksdorf <st@quanttec.com>
Thu, 27 Mar 2014 20:23:12 +0000 (20:23 +0000)
Reviewed in http://llvm-reviews.chandlerc.com/D3190

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204953 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp

index d9208abc2da18fb6fc7d8d1ad44b3483f0628ccd..d0ec4b9fe5a95e9cec716396ec006861c9408210 100644 (file)
@@ -527,8 +527,11 @@ void CXXRecordDecl::addedMember(Decl *D) {
   if (CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D)) {
     SMKind |= SMF_Destructor;
 
-    if (!DD->isImplicit())
+    if (DD->isUserProvided())
       data().HasIrrelevantDestructor = false;
+    // If the destructor is explicitly defaulted and not trivial or not public
+    // or if the destructor is deleted, we clear HasIrrelevantDestructor in
+    // finishedDefaultedOrDeletedMember.
 
     // C++11 [class.dtor]p5:
     //   A destructor is trivial if [...] the destructor is not virtual.
@@ -936,9 +939,11 @@ void CXXRecordDecl::finishedDefaultedOrDeletedMember(CXXMethodDecl *D) {
     else if (Constructor->isConstexpr())
       // We may now know that the constructor is constexpr.
       data().HasConstexprNonCopyMoveConstructor = true;
-  } else if (isa<CXXDestructorDecl>(D))
+  } else if (isa<CXXDestructorDecl>(D)) {
     SMKind |= SMF_Destructor;
-  else if (D->isCopyAssignmentOperator())
+    if (!D->isTrivial() || D->getAccess() != AS_public || D->isDeleted())
+      data().HasIrrelevantDestructor = false;
+  } else if (D->isCopyAssignmentOperator())
     SMKind |= SMF_CopyAssignment;
   else if (D->isMoveAssignmentOperator())
     SMKind |= SMF_MoveAssignment;