From: Hans Wennborg Date: Wed, 15 Feb 2017 23:28:07 +0000 (+0000) Subject: [dllimport] Look through typedefs and arrays in HasNonDllImportDtor X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=abd1d76901c090fe436dbf90e75f397bb64e9b31;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295257 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index d8e1d58115..4353e3a922 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -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(T)) + if (const auto *RT = T->getBaseElementTypeUnsafe()->getAs()) if (CXXRecordDecl *RD = dyn_cast(RT->getDecl())) if (RD->getDestructor() && !RD->getDestructor()->hasAttr()) return true; diff --git a/test/CodeGenCXX/dllimport.cpp b/test/CodeGenCXX/dllimport.cpp index 944c366f88..731239e5ed 100644 --- a/test/CodeGenCXX/dllimport.cpp +++ b/test/CodeGenCXX/dllimport.cpp @@ -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);