blob: 080f1a025cd8bf3d4756e0e1dbfa25743d5d7fef [file] [log] [blame]
David Majnemerba3e5ec2015-03-13 18:26:17 +00001// RUN: %clang_cc1 -emit-llvm -o - -triple=i386-pc-win32 -std=c++11 %s -fcxx-exceptions -fms-extensions | FileCheck %s
David Majnemer7c237072015-03-05 00:46:22 +00002
3// CHECK-DAG: @"\01??_R0?AUY@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"\01??_7type_info@@6B@", i8* null, [8 x i8] c".?AUY@@\00" }, comdat
David Majnemer322fe412015-03-06 23:45:23 +00004// CHECK-DAG: @"_CT??_R0?AUY@@@8??0Y@@QAE@ABU0@@Z8" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 4, i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUY@@@8" to i8*), i32 0, i32 -1, i32 0, i32 8, i8* bitcast (%struct.Y* (%struct.Y*, %struct.Y*, i32)* @"\01??0Y@@QAE@ABU0@@Z" to i8*) }, section ".xdata", comdat
David Majnemer7c237072015-03-05 00:46:22 +00005// CHECK-DAG: @"\01??_R0?AUZ@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"\01??_7type_info@@6B@", i8* null, [8 x i8] c".?AUZ@@\00" }, comdat
David Majnemer322fe412015-03-06 23:45:23 +00006// CHECK-DAG: @"_CT??_R0?AUZ@@@81" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUZ@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* null }, section ".xdata", comdat
David Majnemer7c237072015-03-05 00:46:22 +00007// CHECK-DAG: @"\01??_R0?AUW@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"\01??_7type_info@@6B@", i8* null, [8 x i8] c".?AUW@@\00" }, comdat
David Majnemer999cbf92015-03-10 19:01:51 +00008// CHECK-DAG: @"_CT??_R0?AUW@@@8??0W@@QAE@ABU0@@Z44" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 4, i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUW@@@8" to i8*), i32 4, i32 -1, i32 0, i32 4, i8* bitcast (%struct.W* (%struct.W*, %struct.W*, i32)* @"\01??0W@@QAE@ABU0@@Z" to i8*) }, section ".xdata", comdat
David Majnemer7c237072015-03-05 00:46:22 +00009// CHECK-DAG: @"\01??_R0?AUM@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"\01??_7type_info@@6B@", i8* null, [8 x i8] c".?AUM@@\00" }, comdat
David Majnemer999cbf92015-03-10 19:01:51 +000010// CHECK-DAG: @"_CT??_R0?AUM@@@818" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUM@@@8" to i8*), i32 8, i32 -1, i32 0, i32 1, i8* null }, section ".xdata", comdat
David Majnemer7c237072015-03-05 00:46:22 +000011// CHECK-DAG: @"\01??_R0?AUV@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"\01??_7type_info@@6B@", i8* null, [8 x i8] c".?AUV@@\00" }, comdat
David Majnemer999cbf92015-03-10 19:01:51 +000012// CHECK-DAG: @"_CT??_R0?AUV@@@81044" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUV@@@8" to i8*), i32 0, i32 4, i32 4, i32 1, i8* null }, section ".xdata", comdat
13// CHECK-DAG: @"_CTA5?AUY@@" = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.5 { i32 5, [5 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0?AUY@@@8??0Y@@QAE@ABU0@@Z8", %eh.CatchableType* @"_CT??_R0?AUZ@@@81", %eh.CatchableType* @"_CT??_R0?AUW@@@8??0W@@QAE@ABU0@@Z44", %eh.CatchableType* @"_CT??_R0?AUM@@@818", %eh.CatchableType* @"_CT??_R0?AUV@@@81044"] }, section ".xdata", comdat
David Majnemer322fe412015-03-06 23:45:23 +000014// CHECK-DAG: @"_TI5?AUY@@" = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* bitcast (void (%struct.Y*)* @"\01??_DY@@QAE@XZ" to i8*), i8* null, i8* bitcast (%eh.CatchableTypeArray.5* @"_CTA5?AUY@@" to i8*) }, section ".xdata", comdat
David Majnemerdfa6d202015-03-11 18:36:39 +000015// CHECK-DAG: @"_CT??_R0?AUDefault@@@8??_ODefault@@QAEXAAU0@@Z1" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor13* @"\01??_R0?AUDefault@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* bitcast (void (%struct.Default*, %struct.Default*)* @"\01??_ODefault@@QAEXAAU0@@Z" to i8*) }, section ".xdata", comdat
16// CHECK-DAG: @"_CT??_R0?AUVariadic@@@8??_OVariadic@@QAEXAAU0@@Z1" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor14* @"\01??_R0?AUVariadic@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* bitcast (void (%struct.Variadic*, %struct.Variadic*)* @"\01??_OVariadic@@QAEXAAU0@@Z" to i8*) }, section ".xdata", comdat
17// CHECK-DAG: @"_CT??_R0?AUTemplateWithDefault@@@8??$?_OH@TemplateWithDefault@@QAEXAAU0@@Z1" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor25* @"\01??_R0?AUTemplateWithDefault@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* bitcast (void (%struct.TemplateWithDefault*, %struct.TemplateWithDefault*)* @"\01??$?_OH@TemplateWithDefault@@QAEXAAU0@@Z" to i8*) }, section ".xdata", comdat
David Majnemera1aea9a2015-03-12 17:44:49 +000018// CHECK-DAG: @"_CTA2$$T" = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.2 { i32 2, [2 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0$$T@84", %eh.CatchableType* @"_CT??_R0PAX@84"] }, section ".xdata", comdat
David Majnemerf205f532015-04-04 05:37:48 +000019// CHECK-DAG: @"_CT??_R0P6AXXZ@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0P6AXXZ@8" to i8*), i32 0, i32 -1, i32 0, i32 4, i8* null }, section ".xdata", comdat
20// CHECK-DAG: @_CTA1P6AXXZ = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0P6AXXZ@84"] }, section ".xdata", comdat
21// CHECK-DAG: @_TI1P6AXXZ = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @_CTA1P6AXXZ to i8*) }, section ".xdata", comdat
David Majnemer7c237072015-03-05 00:46:22 +000022
23
24struct N { ~N(); };
25struct M : private N {};
26struct X {};
27struct Z {};
28struct V : private X {};
29struct W : M, virtual V {};
30struct Y : Z, W, virtual V {};
31
32void f(const Y &y) {
33 // CHECK-LABEL: @"\01?f@@YAXABUY@@@Z"
34 // CHECK: call x86_thiscallcc %struct.Y* @"\01??0Y@@QAE@ABU0@@Z"(%struct.Y* %[[mem:.*]], %struct.Y*
35 // CHECK: %[[cast:.*]] = bitcast %struct.Y* %[[mem]] to i8*
David Majnemerd3d76692015-03-06 23:45:20 +000036 // CHECK: call void @_CxxThrowException(i8* %[[cast]], %eh.ThrowInfo* @"_TI5?AUY@@")
37 throw y;
38}
39
40void g(const int *const *y) {
41 // CHECK-LABEL: @"\01?g@@YAXPBQBH@Z"
42 // CHECK: call void @_CxxThrowException(i8* %{{.*}}, %eh.ThrowInfo* @_TIC2PAPBH)
David Majnemer7c237072015-03-05 00:46:22 +000043 throw y;
44}
David Majnemerdfa6d202015-03-11 18:36:39 +000045
46struct Default {
47 Default(Default &, int = 42);
48};
49
50// CHECK-LABEL: @"\01??_ODefault@@QAEXAAU0@@Z"
51// CHECK: %[[src_addr:.*]] = alloca
52// CHECK: %[[this_addr:.*]] = alloca
53// CHECK: store {{.*}} %src, {{.*}} %[[src_addr]], align 4
54// CHECK: store {{.*}} %this, {{.*}} %[[this_addr]], align 4
55// CHECK: %[[this:.*]] = load {{.*}} %[[this_addr]]
56// CHECK: %[[src:.*]] = load {{.*}} %[[src_addr]]
57// CHECK: call x86_thiscallcc {{.*}} @"\01??0Default@@QAE@AAU0@H@Z"({{.*}} %[[this]], {{.*}} %[[src]], i32 42)
58// CHECK: ret void
59
60void h(Default &d) {
61 throw d;
62}
63
64struct Variadic {
65 Variadic(Variadic &, ...);
66};
67
68void i(Variadic &v) {
69 throw v;
70}
71
72// CHECK-LABEL: @"\01??_OVariadic@@QAEXAAU0@@Z"
73// CHECK: %[[src_addr:.*]] = alloca
74// CHECK: %[[this_addr:.*]] = alloca
75// CHECK: store {{.*}} %src, {{.*}} %[[src_addr:.*]], align
76// CHECK: store {{.*}} %this, {{.*}} %[[this_addr:.*]], align
77// CHECK: %[[this:.*]] = load {{.*}} %[[this_addr]]
78// CHECK: %[[src:.*]] = load {{.*}} %[[src_addr]]
David Majnemer67873292015-03-11 21:50:09 +000079// CHECK: call {{.*}} @"\01??0Variadic@@QAA@AAU0@ZZ"({{.*}} %[[this]], {{.*}} %[[src]])
David Majnemerdfa6d202015-03-11 18:36:39 +000080// CHECK: ret void
81
82struct TemplateWithDefault {
83 template <typename T>
84 static int f() {
85 return 0;
86 }
87 template <typename T = int>
88 TemplateWithDefault(TemplateWithDefault &, T = f<T>());
89};
90
91void j(TemplateWithDefault &twd) {
92 throw twd;
93}
David Majnemera1aea9a2015-03-12 17:44:49 +000094
David Majnemerba3e5ec2015-03-13 18:26:17 +000095
David Majnemera1aea9a2015-03-12 17:44:49 +000096void h() {
97 throw nullptr;
98}
David Majnemerba3e5ec2015-03-13 18:26:17 +000099
100namespace std {
101template <typename T>
102void *__GetExceptionInfo(T);
103}
104
105void *GetExceptionInfo_test0() {
106// CHECK-LABEL: @"\01?GetExceptionInfo_test0@@YAPAXXZ"
107// CHECK: ret i8* bitcast (%eh.ThrowInfo* @_TI1H to i8*)
108 return std::__GetExceptionInfo(0);
109}
David Majnemerf205f532015-04-04 05:37:48 +0000110
111void *GetExceptionInfo_test1() {
112// CHECK-LABEL: @"\01?GetExceptionInfo_test1@@YAPAXXZ"
113// CHECK: ret i8* bitcast (%eh.ThrowInfo* @_TI1P6AXXZ to i8*)
114 return std::__GetExceptionInfo<void (*)()>(&h);
115}