2015-02-06 02:56:03 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -fblocks -fms-extensions %s -triple=x86_64-windows-msvc -emit-llvm \
|
|
|
|
// RUN: -o - -mconstructor-aliases -fcxx-exceptions -fexceptions | \
|
|
|
|
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CXXEH
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -fblocks -fms-extensions %s -triple=x86_64-windows-msvc -emit-llvm \
|
2016-12-23 08:23:01 +08:00
|
|
|
// RUN: -o - -mconstructor-aliases -O1 -disable-llvm-passes | \
|
2015-02-06 02:56:03 +08:00
|
|
|
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=NOCXX
|
|
|
|
|
2015-04-15 04:59:00 +08:00
|
|
|
extern "C" unsigned long _exception_code();
|
2015-02-06 02:56:03 +08:00
|
|
|
extern "C" void might_throw();
|
|
|
|
|
|
|
|
struct HasCleanup {
|
|
|
|
HasCleanup();
|
|
|
|
~HasCleanup();
|
|
|
|
int padding;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" void use_cxx() {
|
|
|
|
HasCleanup x;
|
|
|
|
might_throw();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we use __CxxFrameHandler3 for C++ EH.
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CXXEH-LABEL: define dso_local void @use_cxx()
|
2015-06-18 04:53:19 +08:00
|
|
|
// CXXEH-SAME: personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
2018-10-15 23:43:00 +08:00
|
|
|
// CXXEH: call %struct.HasCleanup* @"??0HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}})
|
2015-02-06 02:56:03 +08:00
|
|
|
// CXXEH: invoke void @might_throw()
|
|
|
|
// CXXEH: to label %[[cont:[^ ]*]] unwind label %[[lpad:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CXXEH: [[cont]]
|
2018-03-17 04:36:49 +08:00
|
|
|
// CXXEH: call void @"??1HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}})
|
2015-02-06 02:56:03 +08:00
|
|
|
// CXXEH: ret void
|
|
|
|
//
|
|
|
|
// CXXEH: [[lpad]]
|
2015-10-08 09:13:52 +08:00
|
|
|
// CXXEH: cleanuppad
|
2018-03-17 04:36:49 +08:00
|
|
|
// CXXEH: call void @"??1HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}})
|
2015-10-08 09:13:52 +08:00
|
|
|
// CXXEH: cleanupret
|
2015-02-06 02:56:03 +08:00
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// NOCXX-LABEL: define dso_local void @use_cxx()
|
2015-02-06 02:56:03 +08:00
|
|
|
// NOCXX-NOT: invoke
|
2018-10-15 23:43:00 +08:00
|
|
|
// NOCXX: call %struct.HasCleanup* @"??0HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}})
|
2015-02-06 02:56:03 +08:00
|
|
|
// NOCXX-NOT: invoke
|
|
|
|
// NOCXX: call void @might_throw()
|
|
|
|
// NOCXX-NOT: invoke
|
2018-03-17 04:36:49 +08:00
|
|
|
// NOCXX: call void @"??1HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}})
|
2015-02-06 02:56:03 +08:00
|
|
|
// NOCXX-NOT: invoke
|
|
|
|
// NOCXX: ret void
|
|
|
|
|
|
|
|
extern "C" void use_seh() {
|
|
|
|
__try {
|
|
|
|
might_throw();
|
|
|
|
} __except(1) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we use __C_specific_handler for SEH.
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local void @use_seh()
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
|
2015-02-12 05:40:48 +08:00
|
|
|
// CHECK: invoke void @might_throw() #[[NOINLINE:[0-9]+]]
|
2015-02-06 02:56:03 +08:00
|
|
|
// CHECK: to label %[[cont:[^ ]*]] unwind label %[[lpad:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[lpad]]
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK-NEXT: %[[switch:.*]] = catchswitch within none [label %[[cpad:.*]]] unwind to caller
|
|
|
|
//
|
|
|
|
// CHECK: [[cpad]]
|
|
|
|
// CHECK-NEXT: catchpad within %[[switch]]
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: catchret {{.*}} label %[[except:[^ ]*]]
|
2015-02-06 02:56:03 +08:00
|
|
|
//
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: [[except]]
|
|
|
|
// CHECK: br label %[[ret:[^ ]*]]
|
2015-02-06 02:56:03 +08:00
|
|
|
//
|
|
|
|
// CHECK: [[ret]]
|
|
|
|
// CHECK: ret void
|
2015-10-08 09:13:52 +08:00
|
|
|
//
|
|
|
|
// CHECK: [[cont]]
|
|
|
|
// CHECK: br label %[[ret]]
|
2015-02-06 02:56:03 +08:00
|
|
|
|
2017-10-14 00:55:14 +08:00
|
|
|
extern "C" void nested_finally() {
|
|
|
|
__try {
|
|
|
|
might_throw();
|
|
|
|
} __finally {
|
|
|
|
__try {
|
|
|
|
might_throw();
|
|
|
|
} __finally {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local void @nested_finally() #{{[0-9]+}}
|
2017-10-14 00:55:14 +08:00
|
|
|
// CHECK-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
|
|
|
|
// CHECK: invoke void @might_throw()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: call void @"?fin$0@0@nested_finally@@"(i8 1, i8* {{.*}})
|
2017-10-14 00:55:14 +08:00
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define internal void @"?fin$0@0@nested_finally@@"
|
2017-10-14 00:55:14 +08:00
|
|
|
// CHECK-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
|
|
|
|
// CHECK: invoke void @might_throw()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: call void @"?fin$1@0@nested_finally@@"(i8 1, i8* {{.*}})
|
2017-10-14 00:55:14 +08:00
|
|
|
|
2015-02-06 02:56:03 +08:00
|
|
|
void use_seh_in_lambda() {
|
|
|
|
([]() {
|
|
|
|
__try {
|
|
|
|
might_throw();
|
|
|
|
} __except(1) {
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
HasCleanup x;
|
|
|
|
might_throw();
|
|
|
|
}
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CXXEH-LABEL: define dso_local void @"?use_seh_in_lambda@@YAXXZ"()
|
2015-06-18 04:53:19 +08:00
|
|
|
// CXXEH-SAME: personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
2015-10-08 09:13:52 +08:00
|
|
|
// CXXEH: cleanuppad
|
2015-02-06 02:56:03 +08:00
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// NOCXX-LABEL: define dso_local void @"?use_seh_in_lambda@@YAXXZ"()
|
2015-02-06 02:56:03 +08:00
|
|
|
// NOCXX-NOT: invoke
|
|
|
|
// NOCXX: ret void
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define internal void @"??R<lambda_0>@?0??use_seh_in_lambda@@YAXXZ@QEBA@XZ"(%class.anon* %this)
|
2015-06-18 04:53:19 +08:00
|
|
|
// CXXEH-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
|
2015-02-12 05:40:48 +08:00
|
|
|
// CHECK: invoke void @might_throw() #[[NOINLINE]]
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: catchpad
|
2015-02-12 05:40:48 +08:00
|
|
|
|
2015-04-15 04:59:00 +08:00
|
|
|
static int my_unique_global;
|
|
|
|
|
|
|
|
extern "C" inline void use_seh_in_inline_func() {
|
|
|
|
__try {
|
|
|
|
might_throw();
|
|
|
|
} __except(_exception_code() == 424242) {
|
|
|
|
}
|
|
|
|
__try {
|
|
|
|
might_throw();
|
|
|
|
} __finally {
|
|
|
|
my_unique_global = 1234;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void use_inline() {
|
|
|
|
use_seh_in_inline_func();
|
|
|
|
}
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define linkonce_odr dso_local void @use_seh_in_inline_func() #{{[0-9]+}}
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: invoke void @might_throw()
|
|
|
|
//
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: catchpad {{.*}} [i8* bitcast (i32 (i8*, i8*)* @"?filt$0@0@use_seh_in_inline_func@@" to i8*)]
|
2015-04-15 04:59:00 +08:00
|
|
|
//
|
|
|
|
// CHECK: invoke void @might_throw()
|
|
|
|
//
|
2015-07-08 07:23:31 +08:00
|
|
|
// CHECK: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: call void @"?fin$0@0@use_seh_in_inline_func@@"(i8 0, i8* %[[fp]])
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
//
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: cleanuppad
|
2015-07-08 07:23:31 +08:00
|
|
|
// CHECK: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: call void @"?fin$0@0@use_seh_in_inline_func@@"(i8 1, i8* %[[fp]])
|
2015-04-15 04:59:00 +08:00
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define internal i32 @"?filt$0@0@use_seh_in_inline_func@@"(i8* %exception_pointers, i8* %frame_pointer) #{{[0-9]+}}
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: icmp eq i32 %{{.*}}, 424242
|
|
|
|
// CHECK: zext i1 %{{.*}} to i32
|
|
|
|
// CHECK: ret i32
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define internal void @"?fin$0@0@use_seh_in_inline_func@@"(i8 %abnormal_termination, i8* %frame_pointer) #{{[0-9]+}}
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: store i32 1234, i32* @my_unique_global
|
|
|
|
|
2015-02-12 05:40:48 +08:00
|
|
|
// CHECK: attributes #[[NOINLINE]] = { {{.*noinline.*}} }
|