[cfe-commits] r172207 - in /cfe/trunk: lib/CodeGen/CGException.cpp lib/CodeGen/CGObjCGNU.cpp test/CodeGenObjC/gnu-exceptions.m
David Chisnall
csdavec at swan.ac.uk
Fri Jan 11 07:33:01 PST 2013
Author: theraven
Date: Fri Jan 11 09:33:01 2013
New Revision: 172207
URL: http://llvm.org/viewvc/llvm-project?rev=172207&view=rev
Log:
Enable the new (more C++-like, less broken) EH model when targeting the GNUstep
Objective-C runtime 1.7 or greater.
Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/test/CodeGenObjC/gnu-exceptions.m
Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=172207&r1=172206&r2=172207&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Fri Jan 11 09:33:01 2013
@@ -156,6 +156,7 @@
static const EHPersonality GNU_C;
static const EHPersonality GNU_C_SJLJ;
static const EHPersonality GNU_ObjC;
+ static const EHPersonality GNUstep_ObjC;
static const EHPersonality GNU_ObjCXX;
static const EHPersonality NeXT_ObjC;
static const EHPersonality GNU_CPlusPlus;
@@ -173,6 +174,8 @@
EHPersonality::GNU_ObjC = {"__gnu_objc_personality_v0", "objc_exception_throw"};
const EHPersonality
EHPersonality::GNU_ObjCXX = { "__gnustep_objcxx_personality_v0", 0 };
+const EHPersonality
+EHPersonality::GNUstep_ObjC = { "__gnustep_objc_personality_v0", 0 };
static const EHPersonality &getCPersonality(const LangOptions &L) {
if (L.SjLjExceptions)
@@ -188,6 +191,9 @@
case ObjCRuntime::iOS:
return EHPersonality::NeXT_ObjC;
case ObjCRuntime::GNUstep:
+ if (L.ObjCRuntime.getVersion() >= VersionTuple(1, 7))
+ return EHPersonality::GNUstep_ObjC;
+ // fallthrough
case ObjCRuntime::GCC:
case ObjCRuntime::ObjFW:
return EHPersonality::GNU_ObjC;
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=172207&r1=172206&r2=172207&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Fri Jan 11 09:33:01 2013
@@ -675,6 +675,8 @@
}
public:
CGObjCGNUstep(CodeGenModule &Mod) : CGObjCGNU(Mod, 9, 3) {
+ ObjCRuntime R = CGM.getLangOpts().ObjCRuntime;
+
llvm::StructType *SlotStructTy = llvm::StructType::get(PtrTy,
PtrTy, PtrTy, IntTy, IMPTy, NULL);
SlotTy = llvm::PointerType::getUnqual(SlotStructTy);
@@ -694,6 +696,15 @@
// void _Unwind_Resume_or_Rethrow(void*)
ExceptionReThrowFn.init(&CGM, "_Unwind_Resume_or_Rethrow", VoidTy,
PtrTy, NULL);
+ } else if (R.getVersion() >= VersionTuple(1, 7)) {
+ llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
+ // id objc_begin_catch(void *e)
+ EnterCatchFn.init(&CGM, "objc_begin_catch", IdTy, PtrTy, NULL);
+ // void objc_end_catch(void)
+ ExitCatchFn.init(&CGM, "objc_end_catch", VoidTy, NULL);
+ // void _Unwind_Resume_or_Rethrow(void*)
+ ExceptionReThrowFn.init(&CGM, "objc_exception_rethrow", VoidTy,
+ PtrTy, NULL);
}
llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
SetPropertyAtomic.init(&CGM, "objc_setProperty_atomic", VoidTy, IdTy,
Modified: cfe/trunk/test/CodeGenObjC/gnu-exceptions.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/gnu-exceptions.m?rev=172207&r1=172206&r2=172207&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/gnu-exceptions.m (original)
+++ cfe/trunk/test/CodeGenObjC/gnu-exceptions.m Fri Jan 11 09:33:01 2013
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=gcc -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-1.7 -o - %s | FileCheck -check-prefix=NEW-ABI %s
void opaque(void);
void log(int i);
@@ -21,6 +22,8 @@
// CHECK: call void @log(i32 0)
// CHECK: resume
+ // NEW-ABI: objc_begin_catch
+ // NEW-ABI: objc_end_catch
log(0);
}
More information about the cfe-commits
mailing list