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 { |
| 13 | // CHECK-NEXT:entry: |
Anders Carlsson | 8370c58 | 2009-12-11 00:32:37 +0000 | [diff] [blame] | 14 | // CHECK-NEXT: %exception.ptr = alloca i8* |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 15 | // CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 8) |
Anders Carlsson | 8370c58 | 2009-12-11 00:32:37 +0000 | [diff] [blame] | 16 | // CHECK-NEXT: store i8* %exception, i8** %exception.ptr |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 17 | // CHECK-NEXT: %0 = bitcast i8* %exception to %struct.test1_D* |
| 18 | // CHECK-NEXT: %tmp = bitcast %struct.test1_D* %0 to i8* |
| 19 | // CHECK-NEXT: call void @llvm.memcpy.i64(i8* %tmp, i8* bitcast (%struct.test1_D* @d1 to i8*), i64 8, i32 8) |
| 20 | // CHECK-NEXT: call void @__cxa_throw(i8* %exception, i8* bitcast (%0* @_ZTI7test1_D to i8*), i8* null) noreturn |
| 21 | // CHECK-NEXT: unreachable |
| 22 | |
| 23 | |
| 24 | struct test2_D { |
| 25 | test2_D(const test2_D&o); |
| 26 | test2_D(); |
| 27 | virtual void bar() { } |
| 28 | int i; int j; |
| 29 | } d2; |
| 30 | |
| 31 | void test2() { |
| 32 | throw d2; |
| 33 | } |
| 34 | |
| 35 | // CHECK: define void @_Z5test2v() nounwind { |
| 36 | // CHECK-NEXT:entry: |
Anders Carlsson | 8370c58 | 2009-12-11 00:32:37 +0000 | [diff] [blame] | 37 | // CHECK-NEXT: %exception.ptr = alloca i8* |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 38 | // CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 16) |
Anders Carlsson | 8370c58 | 2009-12-11 00:32:37 +0000 | [diff] [blame] | 39 | // CHECK-NEXT: store i8* %exception, i8** %exception.ptr |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 40 | // CHECK-NEXT: %0 = bitcast i8* %exception to %struct.test2_D* |
Mike Stump | 7695809 | 2009-12-09 23:31:35 +0000 | [diff] [blame] | 41 | // CHECK: invoke void @_ZN7test2_DC1ERKS_(%struct.test2_D* %0, %struct.test2_D* @d2) |
| 42 | // CHECK-NEXT: to label %invoke.cont unwind label %terminate.handler |
| 43 | // CHECK: call void @__cxa_throw(i8* %exception, i8* bitcast (%0* @_ZTI7test2_D to i8*), i8* null) noreturn |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 44 | // CHECK-NEXT: unreachable |
| 45 | |
| 46 | |
| 47 | struct test3_D { |
| 48 | test3_D() { } |
| 49 | test3_D(volatile test3_D&o); |
| 50 | virtual void bar(); |
| 51 | }; |
| 52 | |
| 53 | void test3() { |
| 54 | throw (volatile test3_D *)0; |
| 55 | } |
| 56 | |
| 57 | // CHECK: define void @_Z5test3v() nounwind { |
| 58 | // CHECK-NEXT: entry: |
Anders Carlsson | 8370c58 | 2009-12-11 00:32:37 +0000 | [diff] [blame] | 59 | // CHECK-NEXT: %exception.ptr = alloca i8* |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 60 | // CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 8) |
Anders Carlsson | 8370c58 | 2009-12-11 00:32:37 +0000 | [diff] [blame] | 61 | // CHECK-NEXT: store i8* %exception, i8** %exception.ptr |
Mike Stump | a446343 | 2009-11-20 18:51:28 +0000 | [diff] [blame] | 62 | // CHECK-NEXT: %0 = bitcast i8* %exception to %struct.test3_D** |
| 63 | // CHECK-NEXT: store %struct.test3_D* null, %struct.test3_D** %0 |
| 64 | // CHECK-NEXT: call void @__cxa_throw(i8* %exception, i8* bitcast (%1* @_ZTIPV7test3_D to i8*), i8* null) noreturn |
| 65 | // CHECK-NEXT: unreachable |
| 66 | |
| 67 | |
| 68 | void test4() { |
| 69 | throw; |
| 70 | } |
| 71 | |
| 72 | // CHECK: define void @_Z5test4v() nounwind { |
| 73 | // CHECK-NEXT: entry: |
| 74 | // CHECK-NEXT: call void @__cxa_rethrow() noreturn |
| 75 | // CHECK-NEXT: unreachable |