From 9851cb76e20d35a52aa4e0c9dc73d9894e2426f9 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 1 Apr 2017 17:59:01 +0000 Subject: [PATCH] [ObjC++] Use the correct EH personality in GNU mode Previously, it would just always use the ObjC DWARF personality, even with SjLj or SEH exceptions. Patch by Jonathan Schleifer, test case by me. llvm-svn: 299306 --- clang/lib/CodeGen/CGException.cpp | 4 ++-- clang/test/CodeGenObjCXX/objfw-exceptions.mm | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 clang/test/CodeGenObjCXX/objfw-exceptions.mm diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 228efec51bd0..ca1535182ec1 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -180,8 +180,8 @@ static const EHPersonality &getObjCXXPersonality(const llvm::Triple &T, // The GCC runtime's personality function inherently doesn't support // mixed EH. Use the C++ personality just to avoid returning null. case ObjCRuntime::GCC: - case ObjCRuntime::ObjFW: // XXX: this will change soon - return EHPersonality::GNU_ObjC; + case ObjCRuntime::ObjFW: + return getObjCPersonality(T, L); case ObjCRuntime::GNUstep: return EHPersonality::GNU_ObjCXX; } diff --git a/clang/test/CodeGenObjCXX/objfw-exceptions.mm b/clang/test/CodeGenObjCXX/objfw-exceptions.mm new file mode 100644 index 000000000000..2c3182f543ac --- /dev/null +++ b/clang/test/CodeGenObjCXX/objfw-exceptions.mm @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=objfw -fcxx-exceptions -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-DWARF +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=objfw -fcxx-exceptions -fsjlj-exceptions -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-SJLJ + +@interface OCType @end +void opaque(); + +// CHECK: define void @_Z3foov() +// CHECK-DWARF-SAME: personality i8* bitcast (i32 (...)* @__gnu_objc_personality_v0 to i8*) +// CHECK-SJLJ-SAME: personality i8* bitcast (i32 (...)* @__gnu_objc_personality_sj0 to i8*) +void foo() { +try { +// CHECK: invoke void @_Z6opaquev +opaque(); +} catch (OCType *T) { +// CHECK: landingpad { i8*, i32 } +} +}