1 // RUN: %clang_cc1 -mconstructor-aliases %s -triple x86_64-windows-msvc -fms-extensions -emit-llvm -o - | FileCheck %s 2 3 // FIXME: We should really consider removing -mconstructor-aliases for MS C++ 4 // ABI. The risk of bugs introducing ABI incompatibility under 5 // -mno-constructor-aliases is too high. 6 7 // PR32990 8 9 // Introduces the virtual destructor. We should use the base destructor 10 // directly, no thunk needed. 11 struct __declspec(dllimport) ImportIntroVDtor { 12 virtual ~ImportIntroVDtor() {} 13 }; 14 15 struct BaseClass { 16 virtual ~BaseClass() {} 17 }; 18 19 // Non-virtually inherits from a non-dllimport base class. We should again call 20 // the derived base constructor directly. No need for the complete (aka vbase) 21 // destructor. 22 struct __declspec(dllimport) ImportOverrideVDtor : public BaseClass { 23 virtual ~ImportOverrideVDtor() {} 24 }; 25 26 // Virtually inherits from a non-dllimport base class. This time we need to call 27 // the complete destructor and emit it inline. It's not exported from the DLL, 28 // and it must be emitted. 29 struct __declspec(dllimport) ImportVBaseOverrideVDtor 30 : public virtual BaseClass { 31 virtual ~ImportVBaseOverrideVDtor() {} 32 }; 33 34 extern "C" void testit() { 35 ImportIntroVDtor t1; 36 ImportOverrideVDtor t2; 37 ImportVBaseOverrideVDtor t3; 38 } 39 40 // The destructors are called in reverse order of construction. Only the third 41 // needs the complete destructor (_D). 42 // CHECK-LABEL: define void @testit() 43 // CHECK: call void @"\01??_DImportVBaseOverrideVDtor@@QEAAXXZ"(%struct.ImportVBaseOverrideVDtor* %{{.*}}) 44 // CHECK: call void @"\01??1ImportOverrideVDtor@@UEAA@XZ"(%struct.ImportOverrideVDtor* %{{.*}}) 45 // CHECK: call void @"\01??1ImportIntroVDtor@@UEAA@XZ"(%struct.ImportIntroVDtor* %{{.*}}) 46 47 // CHECK-LABEL: define linkonce_odr void @"\01??_DImportVBaseOverrideVDtor@@QEAAXXZ" 48 // CHECK-LABEL: declare dllimport void @"\01??1ImportOverrideVDtor@@UEAA@XZ" 49 // CHECK-LABEL: declare dllimport void @"\01??1ImportIntroVDtor@@UEAA@XZ" 50