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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @"\01?test_catch@@YAXXZ"(
|
|
|
|
// CHECK: invoke i32 @"\01?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]]
|
|
|
|
// CHECK: %[[CATCHPAD_INT:.*]] = catchpad within %[[CATCHSWITCHPAD]] [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
|
|
|
|
// CHECK: call i32 @"\01?f@@YAHH@Z"(i32 2)
|
|
|
|
// 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]]
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: %[[CATCHPAD_DOUBLE:.*]] = catchpad within %[[CATCHSWITCHPAD]] [%rtti.TypeDescriptor2* @"\01??_R0N@8", i32 0, i8* null]
|
|
|
|
// CHECK: call i32 @"\01?f@@YAHH@Z"(i32 3)
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define {{.*}} @"\01?test_cleanup@@YAXXZ"(
|
|
|
|
// CHECK: invoke i32 @"\01?f@@YAHH@Z"(i32 1)
|
|
|
|
// CHECK: to label %[[LEAVE_FUNC:.*]] unwind label %[[CLEANUP:.*]]
|
|
|
|
|
2015-09-16 07:34:59 +08:00
|
|
|
// CHECK: [[LEAVE_FUNC]]
|
2017-02-14 08:54:11 +08:00
|
|
|
// CHECK: call x86_thiscallcc void @"\01??_DCleanup@@QAEXXZ"(
|
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 []
|
2017-02-14 08:54:11 +08:00
|
|
|
// CHECK: call x86_thiscallcc void @"\01??_DCleanup@@QAEXXZ"(
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: cleanupret from %[[CLEANUPPAD]] unwind to caller
|
2015-09-16 07:30:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
// CHECK-LABEL: define {{.*}} void @"\01??1Cleanup@@QAE@XZ"(
|
|
|
|
// CHECK: invoke i32 @"\01?f@@YAHH@Z"(i32 -1)
|
|
|
|
// 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 []
|
|
|
|
// CHECK-NEXT: call void @"\01?terminate@@YAXXZ"() {{.*}} [ "funclet"(token %[[CLEANUPPAD]]) ]
|
2015-09-16 07:30:42 +08:00
|
|
|
|