Fix <rdar://problem/6640991> Exception handling executes wrong clause (Daniel, please verify).

Also necessary to fix:

<rdar://problem/6632061> [sema] non object types should not be allowed in @catch statements
<rdar://problem/6252237> [sema] qualified id should be disallowed in @catch statements



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65964 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp
index 7293201..c4f6762 100644
--- a/Driver/RewriteObjC.cpp
+++ b/Driver/RewriteObjC.cpp
@@ -1567,7 +1567,7 @@
   bool sawIdTypedCatch = false;
   Stmt *lastCatchBody = 0;
   while (catchList) {
-    Stmt *catchStmt = catchList->getCatchParamStmt();
+    ParmVarDecl *catchDecl = catchList->getCatchParamDecl();
 
     if (catchList == S->getCatchStmts()) 
       buf = "if ("; // we are generating code for the first catch clause
@@ -1592,8 +1592,8 @@
       buf += "1) { id _tmp = _caught;";
       Rewrite.ReplaceText(startLoc, bodyBuf-startBuf+1, 
                           buf.c_str(), buf.size());      
-    } else if (DeclStmt *declStmt = dyn_cast<DeclStmt>(catchStmt)) {
-      QualType t = dyn_cast<ValueDecl>(declStmt->getSolitaryDecl())->getType();
+    } else if (catchDecl) {
+      QualType t = catchDecl->getType();
       if (t == Context->getObjCIdType()) {
         buf += "1) { ";
         ReplaceText(startLoc, lParenLoc-startBuf+1, buf.c_str(), buf.size());
@@ -1622,7 +1622,7 @@
       // Here we replace ") {" with "= _caught;" (which initializes and 
       // declares the @catch parameter).
       ReplaceText(rParenLoc, bodyBuf-rParenBuf+1, buf.c_str(), buf.size());
-    } else if (!isa<NullStmt>(catchStmt)) {
+    } else {
       assert(false && "@catch rewrite bug");
     }
     // make sure all the catch bodies get rewritten!