r295257 - [dllimport] Look through typedefs and arrays in HasNonDllImportDtor

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 15 15:28:08 PST 2017


Author: hans
Date: Wed Feb 15 17:28:07 2017
New Revision: 295257

URL: http://llvm.org/viewvc/llvm-project?rev=295257&view=rev
Log:
[dllimport] Look through typedefs and arrays in HasNonDllImportDtor

The function is used to check whether a type is a class with
non-dllimport destructor. It needs to look through typedefs and array
types.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=295257&r1=295256&r2=295257&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb 15 17:28:07 2017
@@ -1795,7 +1795,7 @@ CodeGenModule::isTriviallyRecursive(cons
 
 // Check if T is a class type with a destructor that's not dllimport.
 static bool HasNonDllImportDtor(QualType T) {
-  if (const RecordType *RT = dyn_cast<RecordType>(T))
+  if (const auto *RT = T->getBaseElementTypeUnsafe()->getAs<RecordType>())
     if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
       if (RD->getDestructor() && !RD->getDestructor()->hasAttr<DLLImportAttr>())
         return true;

Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=295257&r1=295256&r2=295257&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Wed Feb 15 17:28:07 2017
@@ -358,7 +358,7 @@ __declspec(dllimport) inline int *Refere
 USE(ReferencingImportedNew)
 USE(ReferencingImportedDelete)
 struct ClassWithDtor { ~ClassWithDtor() {} };
-struct __declspec(dllimport) ClassWithNonDllImportField { ClassWithDtor t; };
+struct __declspec(dllimport) ClassWithNonDllImportField { using X = ClassWithDtor; X t[2]; };
 struct __declspec(dllimport) ClassWithNonDllImportBase : public ClassWithDtor { };
 USECLASS(ClassWithNonDllImportField);
 USECLASS(ClassWithNonDllImportBase);




More information about the cfe-commits mailing list