pretty-print @try/@catch/@finally from AST as the validation of AST.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43649 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/StmtPrinter.cpp b/AST/StmtPrinter.cpp
index 0953891..ad30910 100644
--- a/AST/StmtPrinter.cpp
+++ b/AST/StmtPrinter.cpp
@@ -322,11 +322,40 @@
 }
 
 void StmtPrinter::VisitObjcAtTryStmt(ObjcAtTryStmt *Node) {
-  Indent() << "@try { /* todo */ }\n";
+  Indent() << "@try";
+  if (CompoundStmt *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
+    PrintRawCompoundStmt(TS);
+    OS << "\n";
+  }
+  
+  for (ObjcAtCatchStmt *catchStmt = 
+         static_cast<ObjcAtCatchStmt *>(Node->getCatchStmts());
+       catchStmt; 
+       catchStmt = 
+         static_cast<ObjcAtCatchStmt *>(catchStmt->getNextCatchStmt())) {
+    Indent() << "@catch(";
+    if (catchStmt->getCatchParamStmt()) {
+      if (DeclStmt *DS = dyn_cast<DeclStmt>(catchStmt->getCatchParamStmt()))
+        PrintRawDecl(DS->getDecl());
+    }
+    OS << ")";
+    if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) 
+      {
+        PrintRawCompoundStmt(CS);
+        OS << "\n";
+      } 
+  }
+  
+  Indent() << "@finally";
+  if (CompoundStmt *FS = dyn_cast<CompoundStmt>(
+        static_cast<ObjcAtFinallyStmt *>(
+          Node->getFinallyStmt())->getFinallyBody())) {
+    PrintRawCompoundStmt(FS);
+    OS << "\n";
+  }  
 }
 
 void StmtPrinter::VisitObjcAtFinallyStmt(ObjcAtFinallyStmt *Node) {
-  Indent() << "@finally { /* todo */ } \n";
 }
 
 void StmtPrinter::VisitObjcAtCatchStmt (ObjcAtCatchStmt *Node) {
@@ -665,7 +694,6 @@
   OS << "]";
 }
 
-
 //===----------------------------------------------------------------------===//
 // Stmt method implementations
 //===----------------------------------------------------------------------===//