Reid Kleckner | fff8e7f | 2015-03-03 19:21:04 +0000 | [diff] [blame] | 1 | // 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 Kleckner | f7e1e75 | 2015-03-03 18:36:38 +0000 | [diff] [blame] | 2 | // 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 Kleckner | a82b5d8 | 2014-05-05 21:12:12 +0000 | [diff] [blame] | 3 | |
David Majnemer | 7c23707 | 2015-03-05 00:46:22 +0000 | [diff] [blame] | 4 | // 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 Majnemer | 322fe41 | 2015-03-06 23:45:23 +0000 | [diff] [blame] | 5 | // 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 Majnemer | b620788 | 2015-03-06 23:56:30 +0000 | [diff] [blame] | 6 | // 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 Majnemer | 7c23707 | 2015-03-05 00:46:22 +0000 | [diff] [blame] | 8 | |
David Majnemer | 5f0dd61 | 2015-03-17 20:35:05 +0000 | [diff] [blame^] | 9 | // TRY-DAG: @llvm.eh.handlermapentry.const.PAH = private unnamed_addr constant %eh.HandlerMapEntry { i32 1, i8* bitcast (%rtti.TypeDescriptor4* @"\01??_R0PAH@8" to i8*) }, section "llvm.metadata" |
| 10 | |
Reid Kleckner | a82b5d8 | 2014-05-05 21:12:12 +0000 | [diff] [blame] | 11 | void external(); |
| 12 | |
| 13 | inline void not_emitted() { |
| 14 | throw int(13); // no error |
| 15 | } |
| 16 | |
| 17 | int main() { |
| 18 | int rv = 0; |
| 19 | #ifdef TRY |
David Majnemer | dbdab40 | 2015-02-25 23:01:21 +0000 | [diff] [blame] | 20 | try { |
| 21 | external(); // TRY: invoke void @"\01?external@@YAXXZ" |
Reid Kleckner | a82b5d8 | 2014-05-05 21:12:12 +0000 | [diff] [blame] | 22 | } catch (int) { |
| 23 | rv = 1; |
Reid Kleckner | fff8e7f | 2015-03-03 19:21:04 +0000 | [diff] [blame] | 24 | // TRY: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* %{{.*}}) |
| 25 | // TRY: call void @llvm.eh.endcatch() |
Reid Kleckner | a82b5d8 | 2014-05-05 21:12:12 +0000 | [diff] [blame] | 26 | } |
| 27 | #endif |
| 28 | #ifdef THROW |
David Majnemer | 7c23707 | 2015-03-05 00:46:22 +0000 | [diff] [blame] | 29 | // THROW: store i32 42, i32* %[[mem_for_throw:.*]] |
| 30 | // THROW: %[[cast:.*]] = bitcast i32* %[[mem_for_throw]] to i8* |
| 31 | // THROW: call void @_CxxThrowException(i8* %[[cast]], %eh.ThrowInfo* @_TI1H) |
David Majnemer | dbdab40 | 2015-02-25 23:01:21 +0000 | [diff] [blame] | 32 | throw int(42); |
Reid Kleckner | a82b5d8 | 2014-05-05 21:12:12 +0000 | [diff] [blame] | 33 | #endif |
| 34 | return rv; |
| 35 | } |
David Majnemer | ad803d4 | 2015-03-15 07:10:01 +0000 | [diff] [blame] | 36 | |
| 37 | #ifdef TRY |
| 38 | // TRY-LABEL: define void @"\01?qual_catch@@YAXXZ" |
| 39 | void qual_catch() { |
| 40 | try { |
| 41 | external(); |
| 42 | } catch (const int *) { |
| 43 | } |
David Majnemer | 5f0dd61 | 2015-03-17 20:35:05 +0000 | [diff] [blame^] | 44 | // TRY: catch %eh.HandlerMapEntry* @llvm.eh.handlermapentry.const.PAH |
| 45 | // TRY: call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.HandlerMapEntry* @llvm.eh.handlermapentry.const.PAH to i8*)) |
David Majnemer | ad803d4 | 2015-03-15 07:10:01 +0000 | [diff] [blame] | 46 | } |
| 47 | #endif |