blob: afd9da6986462d97e6e2ac41f61b5cfa05421a75 [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 {
Mike Stump53b48102010-01-13 21:23:04 +000013// 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 Wang3ecd7852010-04-04 03:10:52 +000018// 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 Stump53b48102010-01-13 21:23:04 +000019// CHECK-NEXT: call void @__cxa_throw(i8* %{{exception|2}}, i8* bitcast (%0* @_ZTI7test1_D to i8*), i8* null) noreturn
Mike Stumpa4463432009-11-20 18:51:28 +000020// CHECK-NEXT: unreachable
21
22
23struct test2_D {
24 test2_D(const test2_D&o);
25 test2_D();
26 virtual void bar() { }
27 int i; int j;
28} d2;
29
30void test2() {
31 throw d2;
32}
33
34// CHECK: define void @_Z5test2v() nounwind {
Mike Stump53b48102010-01-13 21:23:04 +000035// 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 Stumpa4463432009-11-20 18:51:28 +000042// CHECK-NEXT: unreachable
43
44
45struct test3_D {
46 test3_D() { }
47 test3_D(volatile test3_D&o);
48 virtual void bar();
49};
50
51void test3() {
52 throw (volatile test3_D *)0;
53}
54
55// CHECK: define void @_Z5test3v() nounwind {
Mike Stump53b48102010-01-13 21:23:04 +000056// 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 Stumpa4463432009-11-20 18:51:28 +000062// CHECK-NEXT: unreachable
63
64
65void test4() {
66 throw;
67}
68
69// CHECK: define void @_Z5test4v() nounwind {
Mike Stump53b48102010-01-13 21:23:04 +000070// CHECK: call void @__cxa_rethrow() noreturn
Mike Stumpa4463432009-11-20 18:51:28 +000071// CHECK-NEXT: unreachable