From: Fariborz Jahanian Date: Tue, 12 Jan 2010 01:22:23 +0000 (+0000) Subject: Fix rewriting of MacOS sjlj based eh. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=66867c526ce9ae5402bb3d0caf1458ccd8576a5e;p=clang Fix rewriting of MacOS sjlj based eh. Fixes radar 7522880. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93219 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index e8bb18665b..74b2a1eb85 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -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()) { - ObjCInterfaceType *cls; // Should be a pointer to a class. - - cls = dyn_cast(pType->getPointeeType().getTypePtr()); + } else if (t->isObjCObjectPointerType()) { + QualType InterfaceTy = t->getPointeeType(); + const ObjCInterfaceType *cls = // Should be a pointer to a class. + InterfaceTy->getAs(); 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 index 0000000000..5bc80b5509 --- /dev/null +++ b/test/Rewriter/rewrite-eh.m @@ -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