]> granicus.if.org Git - clang/commitdiff
Fix rewriting of MacOS sjlj based eh.
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 12 Jan 2010 01:22:23 +0000 (01:22 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 12 Jan 2010 01:22:23 +0000 (01:22 +0000)
Fixes radar 7522880.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93219 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/RewriteObjC.cpp
test/Rewriter/rewrite-eh.m [new file with mode: 0644]

index e8bb18665b5b9678ae4eaa737ec9693c3f400cb4..74b2a1eb85e9cce0b4e2863a3f0bcc20dc54ee06 100644 (file)
@@ -1757,10 +1757,10 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
         buf += "1) { ";
         ReplaceText(startLoc, lParenLoc-startBuf+1, buf.c_str(), buf.size());
         sawIdTypedCatch = true;
-      } else if (const PointerType *pType = t->getAs<PointerType>()) {
-        ObjCInterfaceType *cls; // Should be a pointer to a class.
-
-        cls = dyn_cast<ObjCInterfaceType>(pType->getPointeeType().getTypePtr());
+      } else if (t->isObjCObjectPointerType()) {
+        QualType InterfaceTy = t->getPointeeType();
+        const ObjCInterfaceType *cls = // Should be a pointer to a class.
+          InterfaceTy->getAs<ObjCInterfaceType>();
         if (cls) {
           buf += "objc_exception_match((struct objc_class *)objc_getClass(\"";
           buf += cls->getDecl()->getNameAsString();
diff --git a/test/Rewriter/rewrite-eh.m b/test/Rewriter/rewrite-eh.m
new file mode 100644 (file)
index 0000000..5bc80b5
--- /dev/null
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -rewrite-objc -o - %s
+// rdar://7522880
+
+@interface NSException
+@end
+
+@interface Foo
+@end
+
+@implementation Foo
+- (void)bar {
+    @try {
+    } @catch (NSException *e) {
+    }
+    @catch (Foo *f) {
+    }
+    @catch (...) {
+    }
+}
+@end