Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t.ll |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 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 { |
Mike Stump | 53b4810 | 2010-01-13 21:23:04 +0000 | [diff] [blame] | 13 | // CHECK: %{{exception.ptr|1}} = alloca i8* |
| 14 | // CHECK-NEXT: %{{exception|2}} = call i8* @__cxa_allocate_exception(i64 8) |
| 15 | // CHECK-NEXT: store i8* %{{exception|2}}, i8** %{{exception.ptr|1}} |
| 16 | // CHECK-NEXT: %{{0|3}} = bitcast i8* %{{exception|2}} to %struct.test1_D* |
| 17 | // CHECK-NEXT: %{{tmp|4}} = bitcast %struct.test1_D* %{{0|3}} to i8* |
Mon P Wang | 3ecd785 | 2010-04-04 03:10:52 +0000 | [diff] [blame] | 18 | // CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %{{tmp|4}}, i8* bitcast (%struct.test1_D* @d1 to i8*), i64 8, i32 8, i1 false) |
Mike Stump | 53b4810 | 2010-01-13 21:23:04 +0000 | [diff] [blame] | 19 | // CHECK-NEXT: call void @__cxa_throw(i8* %{{exception|2}}, i8* bitcast (%0* @_ZTI7test1_D to i8*), i8* null) noreturn |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 20 | // CHECK-NEXT: unreachable |
| 21 | |
| 22 | |
| 23 | struct test2_D { |
| 24 | test2_D(const test2_D&o); |
| 25 | test2_D(); |
| 26 | virtual void bar() { } |
| 27 | int i; int j; |
| 28 | } d2; |
| 29 | |
| 30 | void test2() { |
| 31 | throw d2; |
| 32 | } |
| 33 | |
| 34 | // CHECK: define void @_Z5test2v() nounwind { |
Mike Stump | 53b4810 | 2010-01-13 21:23:04 +0000 | [diff] [blame] | 35 | // CHECK: %{{exception.ptr|1}} = alloca i8* |
| 36 | // CHECK-NEXT: %{{exception|2}} = call i8* @__cxa_allocate_exception(i64 16) |
| 37 | // CHECK-NEXT: store i8* %{{exception|2}}, i8** %{{\1}} |
| 38 | // CHECK-NEXT: %{{0|3}} = bitcast i8* %{{exception|2}} to %struct.test2_D* |
| 39 | // CHECK: invoke void @_ZN7test2_DC1ERKS_(%struct.test2_D* %{{0|3}}, %struct.test2_D* @d2) |
| 40 | // CHECK-NEXT: to label %{{invoke.cont|8}} unwind label %{{terminate.handler|4}} |
| 41 | // CHECK: call void @__cxa_throw(i8* %{{exception|2}}, i8* bitcast (%{{0|3}}* @_ZTI7test2_D to i8*), i8* null) noreturn |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 42 | // CHECK-NEXT: unreachable |
| 43 | |
| 44 | |
| 45 | struct test3_D { |
| 46 | test3_D() { } |
| 47 | test3_D(volatile test3_D&o); |
| 48 | virtual void bar(); |
| 49 | }; |
| 50 | |
| 51 | void test3() { |
| 52 | throw (volatile test3_D *)0; |
| 53 | } |
| 54 | |
| 55 | // CHECK: define void @_Z5test3v() nounwind { |
Mike Stump | 53b4810 | 2010-01-13 21:23:04 +0000 | [diff] [blame] | 56 | // CHECK: %{{exception.ptr|1}} = alloca i8* |
| 57 | // CHECK-NEXT: %{{exception|2}} = call i8* @__cxa_allocate_exception(i64 8) |
| 58 | // CHECK-NEXT: store i8* %{{exception|2}}, i8** %{{exception.ptr|1}} |
| 59 | // CHECK-NEXT: %{{0|3}} = bitcast i8* %{{exception|2}} to %struct.test3_D** |
| 60 | // CHECK-NEXT: store %struct.test3_D* null, %struct.test3_D** |
| 61 | // CHECK-NEXT: call void @__cxa_throw(i8* %{{exception|2}}, i8* bitcast (%1* @_ZTIPV7test3_D to i8*), i8* null) noreturn |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 62 | // CHECK-NEXT: unreachable |
| 63 | |
| 64 | |
| 65 | void test4() { |
| 66 | throw; |
| 67 | } |
| 68 | |
| 69 | // CHECK: define void @_Z5test4v() nounwind { |
Mike Stump | 53b4810 | 2010-01-13 21:23:04 +0000 | [diff] [blame] | 70 | // CHECK: call void @__cxa_rethrow() noreturn |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 71 | // CHECK-NEXT: unreachable |