]> granicus.if.org Git - clang/commitdiff
[dllimport] Look through typedefs and arrays in HasNonDllImportDtor
authorHans Wennborg <hans@hanshq.net>
Wed, 15 Feb 2017 23:28:07 +0000 (23:28 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 15 Feb 2017 23:28:07 +0000 (23:28 +0000)
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.

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

lib/CodeGen/CodeGenModule.cpp
test/CodeGenCXX/dllimport.cpp

index d8e1d58115097d01cb8aab646b9671bc89f779b1..4353e3a922ebe5879291ab65bee3727d4cf8769b 100644 (file)
@@ -1795,7 +1795,7 @@ CodeGenModule::isTriviallyRecursive(const FunctionDecl *FD) {
 
 // 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;
index 944c366f88efa2ebc4538676a2cce8112e9c0051..731239e5eda61e8d0614122ad5f61d49f4bdf2e7 100644 (file)
@@ -358,7 +358,7 @@ __declspec(dllimport) inline int *ReferencingImportedDelete() { delete (int*)nul
 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);