2016-02-20 17:23:41 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
|
2015-09-16 07:30:42 +08:00
|
|
|
|
|
|
|
int f(int);
|
|
|
|
|
|
|
|
void test_catch() {
|
|
|
|
try {
|
|
|
|
f(1);
|
|
|
|
} catch (int) {
|
|
|
|
f(2);
|
|
|
|
} catch (double) {
|
|
|
|
f(3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define dso_local void @"?test_catch@@YAXXZ"(
|
|
|
|
// CHECK: invoke i32 @"?f@@YAHH@Z"(i32 1)
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: to label %[[NORMAL:.*]] unwind label %[[CATCHSWITCH:.*]]
|
2015-09-16 07:30:42 +08:00
|
|
|
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: [[CATCHSWITCH]]
|
|
|
|
// CHECK: %[[CATCHSWITCHPAD:.*]] = catchswitch within none [label %[[CATCH_INT:.*]], label %[[CATCH_DOUBLE:.*]]] unwind to caller
|
2015-09-16 07:30:42 +08:00
|
|
|
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: [[CATCH_INT]]
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: %[[CATCHPAD_INT:.*]] = catchpad within %[[CATCHSWITCHPAD]] [%rtti.TypeDescriptor2* @"??_R0H@8", i32 0, i8* null]
|
|
|
|
// CHECK: call i32 @"?f@@YAHH@Z"(i32 2)
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: catchret from %[[CATCHPAD_INT]] to label %[[LEAVE_INT_CATCH:.*]]
|
2015-09-16 07:30:42 +08:00
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[LEAVE_INT_CATCH]]
|
2015-09-16 07:30:42 +08:00
|
|
|
// CHECK: br label %[[LEAVE_FUNC:.*]]
|
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[LEAVE_FUNC]]
|
2015-09-16 07:30:42 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[CATCH_DOUBLE]]
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: %[[CATCHPAD_DOUBLE:.*]] = catchpad within %[[CATCHSWITCHPAD]] [%rtti.TypeDescriptor2* @"??_R0N@8", i32 0, i8* null]
|
|
|
|
// CHECK: call i32 @"?f@@YAHH@Z"(i32 3)
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: catchret from %[[CATCHPAD_DOUBLE]] to label %[[LEAVE_DOUBLE_CATCH:.*]]
|
2015-09-16 07:30:42 +08:00
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[LEAVE_DOUBLE_CATCH]]
|
2015-09-16 07:30:42 +08:00
|
|
|
// CHECK: br label %[[LEAVE_FUNC]]
|
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[NORMAL]]
|
2015-09-16 07:30:42 +08:00
|
|
|
// CHECK: br label %[[LEAVE_FUNC]]
|
|
|
|
|
|
|
|
struct Cleanup {
|
|
|
|
~Cleanup() { f(-1); }
|
|
|
|
};
|
|
|
|
|
|
|
|
void test_cleanup() {
|
|
|
|
Cleanup C;
|
|
|
|
f(1);
|
|
|
|
}
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define dso_local {{.*}} @"?test_cleanup@@YAXXZ"(
|
|
|
|
// CHECK: invoke i32 @"?f@@YAHH@Z"(i32 1)
|
2015-09-16 07:30:42 +08:00
|
|
|
// CHECK: to label %[[LEAVE_FUNC:.*]] unwind label %[[CLEANUP:.*]]
|
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[LEAVE_FUNC]]
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: call x86_thiscallcc void @"??1Cleanup@@QAE@XZ"(
|
2015-09-16 07:30:42 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[CLEANUP]]
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: %[[CLEANUPPAD:.*]] = cleanuppad within none []
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: call x86_thiscallcc void @"??1Cleanup@@QAE@XZ"(
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: cleanupret from %[[CLEANUPPAD]] unwind to caller
|
2015-09-16 07:30:42 +08:00
|
|
|
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define {{.*}} void @"??1Cleanup@@QAE@XZ"(
|
|
|
|
// CHECK: invoke i32 @"?f@@YAHH@Z"(i32 -1)
|
2015-09-16 07:30:42 +08:00
|
|
|
// CHECK: to label %[[LEAVE_FUNC:.*]] unwind label %[[TERMINATE:.*]]
|
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[LEAVE_FUNC]]
|
2015-09-16 07:30:42 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[TERMINATE]]
|
2016-02-25 01:02:45 +08:00
|
|
|
// CHECK: %[[CLEANUPPAD:.*]] = cleanuppad within none []
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: call void @"?terminate@@YAXXZ"() {{.*}} [ "funclet"(token %[[CLEANUPPAD]]) ]
|
2015-09-16 07:30:42 +08:00
|
|
|
|