blob: 93d6a689ce65011fae3f31b783b2e4807e545931 [file] [log] [blame]
Reid Klecknerfff8e7f2015-03-03 19:21:04 +00001// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTRY | FileCheck %s -check-prefix=TRY
Reid Klecknerf7e1e752015-03-03 18:36:38 +00002// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTHROW | FileCheck %s -check-prefix=THROW
Reid Klecknera82b5d82014-05-05 21:12:12 +00003
David Majnemer7c237072015-03-05 00:46:22 +00004// THROW-DAG: @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
David Majnemer322fe412015-03-06 23:45:23 +00005// 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
David Majnemerb6207882015-03-06 23:56:30 +00006// 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// 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
David Majnemer7c237072015-03-05 00:46:22 +00008
David Majnemer37b417f2015-03-29 21:55:10 +00009// TRY-DAG: @llvm.eh.handlertype.PAH.1 = private unnamed_addr constant %eh.CatchHandlerType { i32 1, i8* bitcast (%rtti.TypeDescriptor4* @"\01??_R0PAH@8" to i8*) }, section "llvm.metadata"
David Majnemer5f0dd612015-03-17 20:35:05 +000010
Reid Klecknera82b5d82014-05-05 21:12:12 +000011void external();
12
13inline void not_emitted() {
14 throw int(13); // no error
15}
16
17int main() {
18 int rv = 0;
19#ifdef TRY
David Majnemerdbdab402015-02-25 23:01:21 +000020 try {
21 external(); // TRY: invoke void @"\01?external@@YAXXZ"
Reid Klecknera82b5d82014-05-05 21:12:12 +000022 } catch (int) {
23 rv = 1;
Reid Kleckner67cf0352015-04-07 00:09:59 +000024 // TRY: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* null)
Reid Klecknerfff8e7f2015-03-03 19:21:04 +000025 // TRY: call void @llvm.eh.endcatch()
Reid Klecknera82b5d82014-05-05 21:12:12 +000026 }
27#endif
28#ifdef THROW
John McCall7f416cc2015-09-08 08:05:57 +000029 // THROW: store i32 42, i32* %[[mem_for_throw:.*]], align 4
David Majnemer7c237072015-03-05 00:46:22 +000030 // THROW: %[[cast:.*]] = bitcast i32* %[[mem_for_throw]] to i8*
31 // THROW: call void @_CxxThrowException(i8* %[[cast]], %eh.ThrowInfo* @_TI1H)
David Majnemerdbdab402015-02-25 23:01:21 +000032 throw int(42);
Reid Klecknera82b5d82014-05-05 21:12:12 +000033#endif
34 return rv;
35}
David Majnemerad803d42015-03-15 07:10:01 +000036
37#ifdef TRY
38// TRY-LABEL: define void @"\01?qual_catch@@YAXXZ"
39void qual_catch() {
40 try {
41 external();
42 } catch (const int *) {
43 }
David Majnemer37b417f2015-03-29 21:55:10 +000044 // TRY: catch %eh.CatchHandlerType* @llvm.eh.handlertype.PAH.1
45 // TRY: call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.PAH.1 to i8*))
David Majnemerad803d42015-03-15 07:10:01 +000046}
47#endif