blob: dd798f4ca32ec0a6578c56aa06b1cae421f74a72 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t.ll
Mike Stumpa4463432009-11-20 18:51:28 +00002// RUN: FileCheck --input-file=%t.ll %s
3
4struct test1_D {
5 double d;
6} d1;
7
8void test1() {
9 throw d1;
10}
11
12// CHECK: define void @_Z5test1v() nounwind {
13// CHECK-NEXT:entry:
Anders Carlsson8370c582009-12-11 00:32:37 +000014// CHECK-NEXT: %exception.ptr = alloca i8*
Mike Stumpa4463432009-11-20 18:51:28 +000015// CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 8)
Anders Carlsson8370c582009-12-11 00:32:37 +000016// CHECK-NEXT: store i8* %exception, i8** %exception.ptr
Mike Stumpa4463432009-11-20 18:51:28 +000017// 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
24struct test2_D {
25 test2_D(const test2_D&o);
26 test2_D();
27 virtual void bar() { }
28 int i; int j;
29} d2;
30
31void test2() {
32 throw d2;
33}
34
35// CHECK: define void @_Z5test2v() nounwind {
36// CHECK-NEXT:entry:
Anders Carlsson8370c582009-12-11 00:32:37 +000037// CHECK-NEXT: %exception.ptr = alloca i8*
Mike Stumpa4463432009-11-20 18:51:28 +000038// CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 16)
Anders Carlsson8370c582009-12-11 00:32:37 +000039// CHECK-NEXT: store i8* %exception, i8** %exception.ptr
Mike Stumpa4463432009-11-20 18:51:28 +000040// CHECK-NEXT: %0 = bitcast i8* %exception to %struct.test2_D*
Mike Stump76958092009-12-09 23:31:35 +000041// 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 Stumpa4463432009-11-20 18:51:28 +000044// CHECK-NEXT: unreachable
45
46
47struct test3_D {
48 test3_D() { }
49 test3_D(volatile test3_D&o);
50 virtual void bar();
51};
52
53void test3() {
54 throw (volatile test3_D *)0;
55}
56
57// CHECK: define void @_Z5test3v() nounwind {
58// CHECK-NEXT: entry:
Anders Carlsson8370c582009-12-11 00:32:37 +000059// CHECK-NEXT: %exception.ptr = alloca i8*
Mike Stumpa4463432009-11-20 18:51:28 +000060// CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 8)
Anders Carlsson8370c582009-12-11 00:32:37 +000061// CHECK-NEXT: store i8* %exception, i8** %exception.ptr
Mike Stumpa4463432009-11-20 18:51:28 +000062// 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
68void 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