summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/eh.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGenCXX/eh.cpp')
-rw-r--r--test/CodeGenCXX/eh.cpp43
1 files changed, 36 insertions, 7 deletions
diff --git a/test/CodeGenCXX/eh.cpp b/test/CodeGenCXX/eh.cpp
index d03dc91..6d79c3e 100644
--- a/test/CodeGenCXX/eh.cpp
+++ b/test/CodeGenCXX/eh.cpp
@@ -136,9 +136,6 @@ namespace test7 {
// CHECK-NEXT: invoke void @__cxa_throw(i8* [[EXNALLOC]], i8* bitcast (i8** @_ZTIi to i8*), i8* null
throw 1;
}
-// This cleanup ends up here for no good reason. It's actually unused.
-// CHECK: load i8** [[EXNALLOCVAR]]
-// CHECK-NEXT: call void @__cxa_free_exception(
// CHECK: [[CAUGHTEXN:%.*]] = call i8* @llvm.eh.exception()
// CHECK-NEXT: store i8* [[CAUGHTEXN]], i8** [[CAUGHTEXNVAR]]
@@ -184,11 +181,7 @@ namespace test8 {
// CHECK-NEXT: invoke void @_ZN5test81AC1ERKS0_(
// CHECK: call i8* @__cxa_begin_catch
// CHECK-NEXT: invoke void @_ZN5test81AD1Ev(
-
// CHECK: call void @__cxa_end_catch()
- // CHECK-NEXT: load
- // CHECK-NEXT: switch
-
// CHECK: ret void
}
}
@@ -220,3 +213,39 @@ namespace test9 {
// CHECK: call i8* @llvm.eh.exception
// CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* {{.*}}, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (i8** @_ZTIi to i8*), i8* null)
}
+
+// __cxa_end_catch can throw for some kinds of caught exceptions.
+namespace test10 {
+ void opaque();
+
+ struct A { ~A(); };
+ struct B { int x; };
+
+ // CHECK: define void @_ZN6test103fooEv()
+ void foo() {
+ A a; // force a cleanup context
+
+ try {
+ // CHECK: invoke void @_ZN6test106opaqueEv()
+ opaque();
+ } catch (int i) {
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: load i32*
+ // CHECK-NEXT: store i32
+ // CHECK-NEXT: call void @__cxa_end_catch() nounwind
+ } catch (B a) {
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @llvm.memcpy
+ // CHECK-NEXT: invoke void @__cxa_end_catch()
+ } catch (...) {
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK-NEXT: invoke void @__cxa_end_catch()
+ }
+
+ // CHECK: call void @_ZN6test101AD1Ev(
+ }
+}
OpenPOWER on IntegriCloud