r204953 - Recognize simple cases of trivial explicitly defaulted public dtors as irrelevant

Stephan Tolksdorf st at quanttec.com
Thu Mar 27 13:23:12 PDT 2014


Author: stephant
Date: Thu Mar 27 15:23:12 2014
New Revision: 204953

URL: http://llvm.org/viewvc/llvm-project?rev=204953&view=rev
Log:
Recognize simple cases of trivial explicitly defaulted public dtors as irrelevant

Reviewed in http://llvm-reviews.chandlerc.com/D3190

Modified:
    cfe/trunk/lib/AST/DeclCXX.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=204953&r1=204952&r2=204953&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Mar 27 15:23:12 2014
@@ -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::finishedDefaultedOrD
     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;





More information about the cfe-commits mailing list