r269087 - Clarify condition, remove redundant check

Derek Schuff via cfe-commits cfe-commits at lists.llvm.org
Tue May 10 10:44:51 PDT 2016


Author: dschuff
Date: Tue May 10 12:44:50 2016
New Revision: 269087

URL: http://llvm.org/viewvc/llvm-project?rev=269087&view=rev
Log:
Clarify condition, remove redundant check

Modified:
    cfe/trunk/lib/CodeGen/CGDeclCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=269087&r1=269086&r2=269087&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue May 10 12:44:50 2016
@@ -87,15 +87,17 @@ static void EmitDeclDestroy(CodeGenFunct
   llvm::Constant *argument;
 
   // Special-case non-array C++ destructors, if they have the right signature
-  // that can be directly registered with __cxa_atexit. If __cxa_atexit is
-  // disabled via a flag, a different helper function is generated anyway.
+  // that can be directly registered with __cxa_atexit.
   const CXXRecordDecl *Record = type->getAsCXXRecordDecl();
   bool CanRegisterDestructor = Record &&
                                !CGM.getCXXABI().HasThisReturn(GlobalDecl(
                                    Record->getDestructor(), Dtor_Complete));
-
-  if (dtorKind == QualType::DK_cxx_destructor && Record &&
-      (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) {
+  // If __cxa_atexit is disabled via a flag, a different helper function is
+  // generated elsewhere which uses atexit instead, and it takes the destructor
+  // directly.
+  bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit;
+  if (Record &&
+      (CanRegisterDestructor || UsingExternalHelper)) {
     assert(!Record->hasTrivialDestructor());
     CXXDestructorDecl *dtor = Record->getDestructor();
 




More information about the cfe-commits mailing list