[clang] Objective C: use C++ exceptions on MinGW+GNUstep (PR #77255)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 7 13:00:36 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 6e1ecd100d7663a91135b1cf6c4a603681b7385b 4cbc22e9b7c53547b97c666b24f191b25ae8866f -- clang/lib/CodeGen/CGException.cpp clang/lib/CodeGen/CGObjCGNU.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 5ace469c92..2b3a5da87f 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -819,7 +819,8 @@ class CGObjCGNUstep : public CGObjCGNU {
       SlotLookupSuperFn.init(&CGM, "objc_slot_lookup_super", SlotTy,
                              PtrToObjCSuperTy, SelectorTy);
       // If we're in ObjC++ mode, then we want to make
-      if (CGM.getTarget().getTriple().isOSCygMing() && isRuntime(ObjCRuntime::GNUstep, 2)) {
+      if (CGM.getTarget().getTriple().isOSCygMing() &&
+          isRuntime(ObjCRuntime::GNUstep, 2)) {
         llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
         // void *__cxa_begin_catch(void *e)
         EnterCatchFn.init(&CGM, "__cxa_begin_catch", PtrTy, PtrTy);
@@ -828,9 +829,9 @@ class CGObjCGNUstep : public CGObjCGNU {
         // void objc_exception_rethrow(void*)
         ExceptionReThrowFn.init(&CGM, "__cxa_rethrow", PtrTy);
       } else if (usesSEHExceptions) {
-          llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
-          // void objc_exception_rethrow(void)
-          ExceptionReThrowFn.init(&CGM, "objc_exception_rethrow", VoidTy);
+        llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
+        // void objc_exception_rethrow(void)
+        ExceptionReThrowFn.init(&CGM, "objc_exception_rethrow", VoidTy);
       } else if (CGM.getLangOpts().CPlusPlus) {
         llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
         // void *__cxa_begin_catch(void *e)
@@ -2218,7 +2219,8 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
 
   // void objc_exception_throw(id);
   ExceptionThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy);
-  if ((CGM.getTarget().getTriple().isOSCygMing() && isRuntime(ObjCRuntime::GNUstep, 2))) {
+  if ((CGM.getTarget().getTriple().isOSCygMing() &&
+       isRuntime(ObjCRuntime::GNUstep, 2))) {
     ExceptionReThrowFn.init(&CGM, "objc_exception_rethrow", VoidTy, IdTy);
   } else {
     ExceptionReThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy);
@@ -2399,7 +2401,9 @@ llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) {
   if (usesSEHExceptions)
     return CGM.getCXXABI().getAddrOfRTTIDescriptor(T);
 
-  if (!CGM.getLangOpts().CPlusPlus && !(CGM.getTarget().getTriple().isOSCygMing() && isRuntime(ObjCRuntime::GNUstep, 2)))
+  if (!CGM.getLangOpts().CPlusPlus &&
+      !(CGM.getTarget().getTriple().isOSCygMing() &&
+        isRuntime(ObjCRuntime::GNUstep, 2)))
     return CGObjCGNU::GetEHType(T);
 
   // For Objective-C++, we want to provide the ability to catch both C++ and
@@ -4005,7 +4009,9 @@ void CGObjCGNU::EmitThrowStmt(CodeGenFunction &CGF,
     ExceptionAsObject = CGF.ObjCEHValueStack.back();
     isRethrow = true;
   }
-  if (isRethrow && (usesSEHExceptions || (CGM.getTarget().getTriple().isOSCygMing() && isRuntime(ObjCRuntime::GNUstep, 2)))) {
+  if (isRethrow &&
+      (usesSEHExceptions || (CGM.getTarget().getTriple().isOSCygMing() &&
+                             isRuntime(ObjCRuntime::GNUstep, 2)))) {
     // For SEH, ExceptionAsObject may be undef, because the catch handler is
     // not passed it for catchalls and so it is not visible to the catch
     // funclet.  The real thrown object will still be live on the stack at this
@@ -4015,8 +4021,7 @@ void CGObjCGNU::EmitThrowStmt(CodeGenFunction &CGF,
     // argument.
     llvm::CallBase *Throw = CGF.EmitRuntimeCallOrInvoke(ExceptionReThrowFn);
     Throw->setDoesNotReturn();
-  }
-  else {
+  } else {
     ExceptionAsObject = CGF.Builder.CreateBitCast(ExceptionAsObject, IdTy);
     llvm::CallBase *Throw =
         CGF.EmitRuntimeCallOrInvoke(ExceptionThrowFn, ExceptionAsObject);

``````````

</details>


https://github.com/llvm/llvm-project/pull/77255


More information about the cfe-commits mailing list