Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t.ll |
| 2 | // RUN: FileCheck --input-file=%t.ll %s |
| 3 | |
| 4 | struct test1_D { |
| 5 | double d; |
| 6 | } d1; |
| 7 | |
| 8 | void test1() { |
| 9 | throw d1; |
| 10 | } |
| 11 | |
| 12 | // CHECK: define void @_Z5test1v() nounwind { |
| 13 | // CHECK-NEXT:entry: |
| 14 | // CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 8) |
| 15 | // CHECK-NEXT: %0 = bitcast i8* %exception to %struct.test1_D* |
| 16 | // CHECK-NEXT: %tmp = bitcast %struct.test1_D* %0 to i8* |
| 17 | // CHECK-NEXT: call void @llvm.memcpy.i64(i8* %tmp, i8* bitcast (%struct.test1_D* @d1 to i8*), i64 8, i32 8) |
| 18 | // CHECK-NEXT: call void @__cxa_throw(i8* %exception, i8* bitcast (%0* @_ZTI7test1_D to i8*), i8* null) noreturn |
| 19 | // CHECK-NEXT: unreachable |
| 20 | |
| 21 | |
| 22 | struct test2_D { |
| 23 | test2_D(const test2_D&o); |
| 24 | test2_D(); |
| 25 | virtual void bar() { } |
| 26 | int i; int j; |
| 27 | } d2; |
| 28 | |
| 29 | void test2() { |
| 30 | throw d2; |
| 31 | } |
| 32 | |
| 33 | // CHECK: define void @_Z5test2v() nounwind { |
| 34 | // CHECK-NEXT:entry: |
| 35 | // CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 16) |
| 36 | // CHECK-NEXT: %0 = bitcast i8* %exception to %struct.test2_D* |
| 37 | // CHECK-NEXT: call void @_ZN7test2_DC1ERKS_(%struct.test2_D* %0, %struct.test2_D* @d2) |
| 38 | // CHECK-NEXT: call void @__cxa_throw(i8* %exception, i8* bitcast (%0* @_ZTI7test2_D to i8*), i8* null) noreturn |
| 39 | // CHECK-NEXT: unreachable |
| 40 | |
| 41 | |
| 42 | struct test3_D { |
| 43 | test3_D() { } |
| 44 | test3_D(volatile test3_D&o); |
| 45 | virtual void bar(); |
| 46 | }; |
| 47 | |
| 48 | void test3() { |
| 49 | throw (volatile test3_D *)0; |
| 50 | } |
| 51 | |
| 52 | // CHECK: define void @_Z5test3v() nounwind { |
| 53 | // CHECK-NEXT: entry: |
| 54 | // CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 8) |
| 55 | // CHECK-NEXT: %0 = bitcast i8* %exception to %struct.test3_D** |
| 56 | // CHECK-NEXT: store %struct.test3_D* null, %struct.test3_D** %0 |
| 57 | // CHECK-NEXT: call void @__cxa_throw(i8* %exception, i8* bitcast (%1* @_ZTIPV7test3_D to i8*), i8* null) noreturn |
| 58 | // CHECK-NEXT: unreachable |
| 59 | |
| 60 | |
| 61 | void test4() { |
| 62 | throw; |
| 63 | } |
| 64 | |
| 65 | // CHECK: define void @_Z5test4v() nounwind { |
| 66 | // CHECK-NEXT: entry: |
| 67 | // CHECK-NEXT: call void @__cxa_rethrow() noreturn |
| 68 | // CHECK-NEXT: unreachable |