]> granicus.if.org Git - clang/commitdiff
Fix foreign exception handling (GNU runtime).
authorDavid Chisnall <csdavec@swan.ac.uk>
Wed, 16 Mar 2011 15:44:28 +0000 (15:44 +0000)
committerDavid Chisnall <csdavec@swan.ac.uk>
Wed, 16 Mar 2011 15:44:28 +0000 (15:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127736 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCGNU.cpp

index 5bd45a01c4beb93235cedeba1f38a264b6d8b362..fa873116623ff618263dc2edbb28a34aa56d6676 100644 (file)
@@ -1993,17 +1993,28 @@ void CGObjCGNU::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
 
       // @catch() and @catch(id) both catch any ObjC exception.
       // Treat them as catch-alls.
-      // FIXME: this is what this code was doing before, but should 'id'
       // really be catching foreign exceptions?
-      if (!CatchDecl
-          || CatchDecl->getType()->isObjCIdType()
-          || CatchDecl->getType()->isObjCQualifiedIdType()) {
-
+      
+      if (!CatchDecl) {
         Handler.TypeInfo = 0; // catch-all
-
         // Don't consider any other catches.
         break;
       }
+      if (CatchDecl->getType()->isObjCIdType()
+          || CatchDecl->getType()->isObjCQualifiedIdType()) {
+        // With the old ABI, there was only one kind of catchall, which broke
+        // foreign exceptions.  With the new ABI, we use __objc_id_typeinfo as
+        // a pointer indicating object catchalls, and NULL to indicate real
+        // catchalls
+        if (CGM.getLangOptions().ObjCNonFragileABI) {
+          Handler.TypeInfo = MakeConstantString("@id");
+          continue;
+        } else {
+          Handler.TypeInfo = 0; // catch-all
+          // Don't consider any other catches.
+          break;
+        }
+      }
 
       // All other types should be Objective-C interface pointer types.
       const ObjCObjectPointerType *OPT =