diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-02-05 18:56:03 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-02-05 18:56:03 +0000 |
commit | deeddeced312a21b8454336cfab9fe2b58863cf8 (patch) | |
tree | 87170d3e4cedf4bc76f9916cbdd5d74f33e676e1 /clang/test/CodeGenCXX/exceptions-seh.cpp | |
parent | c9dd02066cc0528da28bd887e8dbdb3bd9c68165 (diff) | |
download | bcm5719-llvm-deeddeced312a21b8454336cfab9fe2b58863cf8.tar.gz bcm5719-llvm-deeddeced312a21b8454336cfab9fe2b58863cf8.zip |
Re-land r228258 and make clang-cl's /EHs- disable -fexceptions again
After r228258, Clang started emitting C++ EH IR that LLVM wasn't ready
to deal with, even when exceptions were disabled with /EHs-. This time,
make /EHs- turn off -fexceptions while still emitting exceptional
constructs in functions using __try. Since Sema rejects C++ exception
handling constructs before CodeGen, landingpads should only appear in
such functions as the result of a __try.
llvm-svn: 228329
Diffstat (limited to 'clang/test/CodeGenCXX/exceptions-seh.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/exceptions-seh.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/exceptions-seh.cpp b/clang/test/CodeGenCXX/exceptions-seh.cpp new file mode 100644 index 00000000000..e76f0ea5c07 --- /dev/null +++ b/clang/test/CodeGenCXX/exceptions-seh.cpp @@ -0,0 +1,95 @@ +// 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 \ +// RUN: -o - -mconstructor-aliases | \ +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=NOCXX + +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. + +// CXXEH-LABEL: define void @use_cxx() +// CXXEH: call %struct.HasCleanup* @"\01??0HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}}) +// CXXEH: invoke void @might_throw() +// CXXEH: to label %[[cont:[^ ]*]] unwind label %[[lpad:[^ ]*]] +// +// CXXEH: [[cont]] +// CXXEH: call void @"\01??1HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}}) +// CXXEH: ret void +// +// CXXEH: [[lpad]] +// CXXEH: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) +// CXXEH-NEXT: cleanup +// CXXEH: call void @"\01??1HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}}) +// CXXEH: br label %[[resume:[^ ]*]] +// +// CXXEH: [[resume]] +// CXXEH: resume + +// NOCXX-LABEL: define void @use_cxx() +// NOCXX-NOT: invoke +// NOCXX: call %struct.HasCleanup* @"\01??0HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}}) +// NOCXX-NOT: invoke +// NOCXX: call void @might_throw() +// NOCXX-NOT: invoke +// NOCXX: call void @"\01??1HasCleanup@@QEAA@XZ"(%struct.HasCleanup* %{{.*}}) +// 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. + +// CHECK-LABEL: define void @use_seh() +// CHECK: invoke void @might_throw() +// CHECK: to label %[[cont:[^ ]*]] unwind label %[[lpad:[^ ]*]] +// +// CHECK: [[cont]] +// CHECK: br label %[[ret:[^ ]*]] +// +// CHECK: [[lpad]] +// CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) +// CHECK-NEXT: catch i8* +// +// CHECK: br label %[[ret]] +// +// CHECK: [[ret]] +// CHECK: ret void + +void use_seh_in_lambda() { + ([]() { + __try { + might_throw(); + } __except(1) { + } + })(); + HasCleanup x; + might_throw(); +} + +// CXXEH-LABEL: define void @"\01?use_seh_in_lambda@@YAXXZ"() +// CXXEH: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) + +// NOCXX-LABEL: define void @"\01?use_seh_in_lambda@@YAXXZ"() +// NOCXX-NOT: invoke +// NOCXX: ret void + +// CHECK-LABEL: define internal void @"\01??R<lambda_0>@?use_seh_in_lambda@@YAXXZ@QEBAXXZ"(%class.anon* %this) +// CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) |