1 // RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \ 2 // RUN: -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \ 3 // RUN: -disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \ 4 // RUN: FileCheck %s 5 6 struct CtorWithClosure { 7 __declspec(dllexport) CtorWithClosure(...) {} 8 // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorWithClosure@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat 9 // CHECK: %[[this_addr:.*]] = alloca %struct.CtorWithClosure*, align 4 10 // CHECK: store %struct.CtorWithClosure* %this, %struct.CtorWithClosure** %[[this_addr]], align 4 11 // CHECK: %[[this:.*]] = load %struct.CtorWithClosure*, %struct.CtorWithClosure** %[[this_addr]] 12 // CHECK: call %struct.CtorWithClosure* (%struct.CtorWithClosure*, ...) @"\01??0CtorWithClosure@@QAA@ZZ"(%struct.CtorWithClosure* %[[this]]) 13 // CHECK: ret void 14 }; 15 16 struct CtorWithClosureOutOfLine { 17 __declspec(dllexport) CtorWithClosureOutOfLine(...); 18 }; 19 CtorWithClosureOutOfLine::CtorWithClosureOutOfLine(...) {} 20 // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorWithClosureOutOfLine@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat 21 22 #define DELETE_IMPLICIT_MEMBERS(ClassName) \ 23 ClassName(ClassName &&) = delete; \ 24 ClassName(ClassName &) = delete; \ 25 ~ClassName() = delete; \ 26 ClassName &operator=(ClassName &) = delete 27 28 struct __declspec(dllexport) ClassWithClosure { 29 DELETE_IMPLICIT_MEMBERS(ClassWithClosure); 30 ClassWithClosure(...) {} 31 // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FClassWithClosure@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat 32 // CHECK: %[[this_addr:.*]] = alloca %struct.ClassWithClosure*, align 4 33 // CHECK: store %struct.ClassWithClosure* %this, %struct.ClassWithClosure** %[[this_addr]], align 4 34 // CHECK: %[[this:.*]] = load %struct.ClassWithClosure*, %struct.ClassWithClosure** %[[this_addr]] 35 // CHECK: call %struct.ClassWithClosure* (%struct.ClassWithClosure*, ...) @"\01??0ClassWithClosure@@QAA@ZZ"(%struct.ClassWithClosure* %[[this]]) 36 // CHECK: ret void 37 }; 38 39 template <typename T> struct TemplateWithClosure { 40 TemplateWithClosure(int x = sizeof(T)) {} 41 }; 42 extern template struct TemplateWithClosure<char>; 43 template struct __declspec(dllexport) TemplateWithClosure<char>; 44 extern template struct TemplateWithClosure<int>; 45 template struct __declspec(dllexport) TemplateWithClosure<int>; 46 47 // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_F?$TemplateWithClosure@D@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat 48 // CHECK: call {{.*}} @"\01??0?$TemplateWithClosure@D@@QAE@H@Z"({{.*}}, i32 1) 49 50 // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_F?$TemplateWithClosure@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat 51 // CHECK: call {{.*}} @"\01??0?$TemplateWithClosure@H@@QAE@H@Z"({{.*}}, i32 4) 52 53 struct __declspec(dllexport) NestedOuter { 54 DELETE_IMPLICIT_MEMBERS(NestedOuter); 55 NestedOuter(void *p = 0) {} 56 struct __declspec(dllexport) NestedInner { 57 DELETE_IMPLICIT_MEMBERS(NestedInner); 58 NestedInner(void *p = 0) {} 59 }; 60 }; 61 62 // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FNestedOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat 63 // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FNestedInner@NestedOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat 64 65 struct HasDtor { 66 ~HasDtor(); 67 int o; 68 }; 69 struct HasImplicitDtor1 { HasDtor o; }; 70 struct HasImplicitDtor2 { HasDtor o; }; 71 struct __declspec(dllexport) CtorClosureInline { 72 CtorClosureInline(const HasImplicitDtor1 &v = {}) {} 73 }; 74 struct __declspec(dllexport) CtorClosureOutOfLine { 75 CtorClosureOutOfLine(const HasImplicitDtor2 &v = {}); 76 }; 77 CtorClosureOutOfLine::CtorClosureOutOfLine(const HasImplicitDtor2 &v) {} 78 79 // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorClosureInline@@QAEXXZ" 80 // CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"\01??1HasImplicitDtor1@@QAE@XZ" 81 // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorClosureOutOfLine@@QAEXXZ" 82 // CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"\01??1HasImplicitDtor2@@QAE@XZ" 83