Skip to content

Commit

Permalink
Objective C/MinGW: Use functions in libobjc2 for exception handling
Browse files Browse the repository at this point in the history
The current implementation uses functions which are declared in the
C++ standard library to throw and catch excpetions.
This requires linking with said library, which most toolchains do not
do natively.
  • Loading branch information
qmfrederik committed Feb 21, 2024
1 parent 0fb3d42 commit 10db940
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGException.cpp
Expand Up @@ -159,7 +159,7 @@ static const EHPersonality &getObjCPersonality(const TargetInfo &Target,
return EHPersonality::NeXT_ObjC;
case ObjCRuntime::GNUstep:
if (T.isOSCygMing())
return EHPersonality::GNU_CPlusPlus_SEH;
return EHPersonality::GNU_ObjC_SEH;
else if (L.ObjCRuntime.getVersion() >= VersionTuple(1, 7))
return EHPersonality::GNUstep_ObjC;
[[fallthrough]];
Expand Down Expand Up @@ -216,7 +216,7 @@ static const EHPersonality &getObjCXXPersonality(const TargetInfo &Target,
return getObjCPersonality(Target, L);

case ObjCRuntime::GNUstep:
return Target.getTriple().isOSCygMing() ? EHPersonality::GNU_CPlusPlus_SEH
return Target.getTriple().isOSCygMing() ? EHPersonality::GNU_ObjC_SEH
: EHPersonality::GNU_ObjCXX;

// The GCC runtime's personality function inherently doesn't support
Expand Down
12 changes: 6 additions & 6 deletions clang/lib/CodeGen/CGObjCGNU.cpp
Expand Up @@ -829,12 +829,12 @@ class CGObjCGNUstep : public CGObjCGNU {
// If we're in ObjC++ mode, then we want to make
llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
if (usesCxxExceptions) {
// void *__cxa_begin_catch(void *e)
EnterCatchFn.init(&CGM, "__cxa_begin_catch", PtrTy, PtrTy);
// void __cxa_end_catch(void)
ExitCatchFn.init(&CGM, "__cxa_end_catch", VoidTy);
// void objc_exception_rethrow(void*)
ExceptionReThrowFn.init(&CGM, "__cxa_rethrow", PtrTy);
// void *objc_begin_catch(void *e)
EnterCatchFn.init(&CGM, "objc_begin_catch", PtrTy, PtrTy);
// void objc_end_catch(void)
ExitCatchFn.init(&CGM, "objc_end_catch", VoidTy);
// void objc_exception_rethrow(void)
ExceptionReThrowFn.init(&CGM, "objc_exception_rethrow", VoidTy);
} else if (usesSEHExceptions) {
// void objc_exception_rethrow(void)
ExceptionReThrowFn.init(&CGM, "objc_exception_rethrow", VoidTy);
Expand Down

0 comments on commit 10db940

Please sign in to comment.