blob: ec457dd4187f8032cade97cf56a017d27c9e65f6 [file] [log] [blame]
Mike Stumpa4463432009-11-20 18:51:28 +00001// 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
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:
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
22struct test2_D {
23 test2_D(const test2_D&o);
24 test2_D();
25 virtual void bar() { }
26 int i; int j;
27} d2;
28
29void 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*
Mike Stump76958092009-12-09 23:31:35 +000037// CHECK: invoke void @_ZN7test2_DC1ERKS_(%struct.test2_D* %0, %struct.test2_D* @d2)
38// CHECK-NEXT: to label %invoke.cont unwind label %terminate.handler
39// CHECK: call void @__cxa_throw(i8* %exception, i8* bitcast (%0* @_ZTI7test2_D to i8*), i8* null) noreturn
Mike Stumpa4463432009-11-20 18:51:28 +000040// CHECK-NEXT: unreachable
41
42
43struct test3_D {
44 test3_D() { }
45 test3_D(volatile test3_D&o);
46 virtual void bar();
47};
48
49void test3() {
50 throw (volatile test3_D *)0;
51}
52
53// CHECK: define void @_Z5test3v() nounwind {
54// CHECK-NEXT: entry:
55// CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 8)
56// CHECK-NEXT: %0 = bitcast i8* %exception to %struct.test3_D**
57// CHECK-NEXT: store %struct.test3_D* null, %struct.test3_D** %0
58// CHECK-NEXT: call void @__cxa_throw(i8* %exception, i8* bitcast (%1* @_ZTIPV7test3_D to i8*), i8* null) noreturn
59// CHECK-NEXT: unreachable
60
61
62void test4() {
63 throw;
64}
65
66// CHECK: define void @_Z5test4v() nounwind {
67// CHECK-NEXT: entry:
68// CHECK-NEXT: call void @__cxa_rethrow() noreturn
69// CHECK-NEXT: unreachable