Improve the AST representation of Objective-C @try/@catch/@finally
statements. Instead of the @try having a single @catch, where all of
the @catch's were chained (using an O(n^2) algorithm nonetheless),
@try just holds an array of its @catch blocks. The resulting AST is
slightly more compact (not important) and better represents the actual
language semantics (good).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102221 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 36162f7..a248c5a 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -1781,11 +1781,12 @@
   bool HasCatchAll = false;
   // Only @try blocks are allowed @catch blocks, but both can have @finally
   if (isTry) {
-    if (const ObjCAtCatchStmt* CatchStmt =
-      cast<ObjCAtTryStmt>(S).getCatchStmts())  {
+    if (cast<ObjCAtTryStmt>(S).getNumCatchStmts()) {
+      const ObjCAtTryStmt &AtTry = cast<ObjCAtTryStmt>(S);
       CGF.setInvokeDest(CatchInCatch);
 
-      for (; CatchStmt; CatchStmt = CatchStmt->getNextCatchStmt()) {
+      for (unsigned I = 0, N = AtTry.getNumCatchStmts(); I != N; ++I) {
+        const ObjCAtCatchStmt *CatchStmt = AtTry.getCatchStmt(I);
         const ParmVarDecl *CatchDecl = CatchStmt->getCatchParamDecl();
         Handlers.push_back(std::make_pair(CatchDecl,
                                           CatchStmt->getCatchBody()));