1*67e74705SXin Li // RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTRY | FileCheck %s -check-prefix=TRY
2*67e74705SXin Li // RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTHROW | FileCheck %s -check-prefix=THROW
3*67e74705SXin Li
4*67e74705SXin Li // THROW-DAG: @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
5*67e74705SXin Li // THROW-DAG: @"_CT??_R0H@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*), i32 0, i32 -1, i32 0, i32 4, i8* null }, section ".xdata", comdat
6*67e74705SXin Li // THROW-DAG: @_CTA1H = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0H@84"] }, section ".xdata", comdat
7*67e74705SXin Li // THROW-DAG: @_TI1H = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @_CTA1H to i8*) }, section ".xdata", comdat
8*67e74705SXin Li
9*67e74705SXin Li void external();
10*67e74705SXin Li
not_emitted()11*67e74705SXin Li inline void not_emitted() {
12*67e74705SXin Li throw int(13); // no error
13*67e74705SXin Li }
14*67e74705SXin Li
main()15*67e74705SXin Li int main() {
16*67e74705SXin Li int rv = 0;
17*67e74705SXin Li #ifdef TRY
18*67e74705SXin Li try {
19*67e74705SXin Li external(); // TRY: invoke void @"\01?external@@YAXXZ"
20*67e74705SXin Li } catch (int) {
21*67e74705SXin Li rv = 1;
22*67e74705SXin Li // TRY: catchpad within {{.*}} [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
23*67e74705SXin Li // TRY: catchret
24*67e74705SXin Li }
25*67e74705SXin Li #endif
26*67e74705SXin Li #ifdef THROW
27*67e74705SXin Li // THROW: store i32 42, i32* %[[mem_for_throw:.*]], align 4
28*67e74705SXin Li // THROW: %[[cast:.*]] = bitcast i32* %[[mem_for_throw]] to i8*
29*67e74705SXin Li // THROW: call void @_CxxThrowException(i8* %[[cast]], %eh.ThrowInfo* @_TI1H)
30*67e74705SXin Li throw int(42);
31*67e74705SXin Li #endif
32*67e74705SXin Li return rv;
33*67e74705SXin Li }
34*67e74705SXin Li
35*67e74705SXin Li #ifdef TRY
36*67e74705SXin Li // TRY-LABEL: define void @"\01?qual_catch@@YAXXZ"
qual_catch()37*67e74705SXin Li void qual_catch() {
38*67e74705SXin Li try {
39*67e74705SXin Li external();
40*67e74705SXin Li } catch (const int *) {
41*67e74705SXin Li }
42*67e74705SXin Li // TRY: catchpad within {{.*}} [%rtti.TypeDescriptor4* @"\01??_R0PAH@8", i32 1, i8* null]
43*67e74705SXin Li // TRY: catchret
44*67e74705SXin Li }
45*67e74705SXin Li #endif
46