summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/exceptions-cxx-new.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-09-15 23:30:42 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-09-15 23:30:42 +0000
commit834c5128d8ba00da3def95465557361abd651033 (patch)
treed1db66475a43606d20173a2dfaa1cf6677b52602 /clang/test/CodeGenCXX/exceptions-cxx-new.cpp
parent63bd0db071e92662719934065fbf656587c6d35e (diff)
downloadbcm5719-llvm-834c5128d8ba00da3def95465557361abd651033.tar.gz
bcm5719-llvm-834c5128d8ba00da3def95465557361abd651033.zip
[MS ABI] Add a C++ test for -fnew-ms-eh
llvm-svn: 247742
Diffstat (limited to 'clang/test/CodeGenCXX/exceptions-cxx-new.cpp')
-rw-r--r--clang/test/CodeGenCXX/exceptions-cxx-new.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/exceptions-cxx-new.cpp b/clang/test/CodeGenCXX/exceptions-cxx-new.cpp
new file mode 100644
index 00000000000..5bc3a969a0a
--- /dev/null
+++ b/clang/test/CodeGenCXX/exceptions-cxx-new.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -fexceptions -fcxx-exceptions -fnew-ms-eh -emit-llvm -o - -std=c++11 | FileCheck %s
+
+int f(int);
+
+void test_catch() {
+ try {
+ f(1);
+ } catch (int) {
+ f(2);
+ } catch (double) {
+ f(3);
+ }
+}
+
+// CHECK-LABEL: define void @"\01?test_catch@@YAXXZ"(
+// CHECK: invoke i32 @"\01?f@@YAHH@Z"(i32 1)
+// CHECK: to label %[[NORMAL:.*]] unwind label %[[CATCH_INT:.*]]
+
+// CHECK: [[CATCH_INT]]:
+// CHECK: %[[CATCHPAD_INT:.*]] = catchpad [{{.*}} @llvm.eh.handlertype.H.0, i8* null]
+// CHECK: to label %[[CATCH_INT_HANDLER:.*]] unwind label %[[CATCH_DOUBLE:.*]]
+
+// CHECK: [[CATCH_INT_HANDLER]]:
+// CHECK: invoke i32 @"\01?f@@YAHH@Z"(i32 2)
+// CHECK: to label %[[CATCH_INT_DONE:.*]] unwind label %[[CATCHENDPAD:.*]]
+
+// CHECK: [[CATCH_INT_DONE]]:
+// CHECK: catchret %[[CATCHPAD_INT]] to label %[[LEAVE_INT_CATCH:.*]]
+
+// CHECK: [[LEAVE_INT_CATCH]]:
+// CHECK: br label %[[LEAVE_FUNC:.*]]
+
+// CHECK: [[LEAVE_FUNC]]:
+// CHECK: ret void
+
+// CHECK: [[CATCH_DOUBLE]]:
+// CHECK: %[[CATCHPAD_DOUBLE:.*]] = catchpad [{{.*}} @llvm.eh.handlertype.N.0, i8* null]
+// CHECK: to label %[[CATCH_DOUBLE_HANDLER:.*]] unwind label %[[CATCHENDPAD]]
+
+// CHECK: [[CATCH_DOUBLE_HANDLER]]:
+// CHECK: invoke i32 @"\01?f@@YAHH@Z"(i32 3)
+// CHECK: to label %[[CATCH_DOUBLE_DONE:.*]] unwind label %[[CATCHENDPAD]]
+
+// CHECK: [[CATCH_DOUBLE_DONE]]:
+// CHECK: catchret %[[CATCHPAD_DOUBLE]] to label %[[LEAVE_DOUBLE_CATCH:.*]]
+
+// CHECK: [[LEAVE_DOUBLE_CATCH]]:
+// CHECK: br label %[[LEAVE_FUNC]]
+
+// CHECK: [[CATCHENDPAD]]:
+// CHECK: catchendpad unwind to caller
+
+// CHECK: [[NORMAL]]:
+// CHECK: br label %[[LEAVE_FUNC]]
+
+struct Cleanup {
+ ~Cleanup() { f(-1); }
+};
+
+void test_cleanup() {
+ Cleanup C;
+ f(1);
+}
+
+// CHECK-LABEL: define {{.*}} @"\01?test_cleanup@@YAXXZ"(
+// CHECK: invoke i32 @"\01?f@@YAHH@Z"(i32 1)
+// CHECK: to label %[[LEAVE_FUNC:.*]] unwind label %[[CLEANUP:.*]]
+
+// CHECK: [[LEAVE_FUNC]]:
+// CHECK: call x86_thiscallcc void @"\01??_DCleanup@@QAE@XZ"(
+// CHECK: ret void
+
+// CHECK: [[CLEANUP]]:
+// CHECK: %[[CLEANUPPAD:.*]] = cleanuppad []
+// CHECK: call x86_thiscallcc void @"\01??_DCleanup@@QAE@XZ"(
+// CHECK: cleanupret %[[CLEANUPPAD]] unwind to caller
+
+
+// CHECK-LABEL: define {{.*}} void @"\01??1Cleanup@@QAE@XZ"(
+// CHECK: entry:
+// CHECK: invoke i32 @"\01?f@@YAHH@Z"(i32 -1)
+// CHECK: to label %[[LEAVE_FUNC:.*]] unwind label %[[TERMINATE:.*]]
+
+// CHECK: [[LEAVE_FUNC]]:
+// CHECK: ret void
+
+// CHECK: [[TERMINATE]]:
+// CHECK: terminatepad [void ()* @"\01?terminate@@YAXXZ"] unwind to caller
+
OpenPOWER on IntegriCloud