Implement function-try-blocks. However, there's a very subtle bug that I can't track down.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70155 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/RewriteBlocks.cpp b/tools/clang-cc/RewriteBlocks.cpp
index a9324e6..f9ed0ec 100644
--- a/tools/clang-cc/RewriteBlocks.cpp
+++ b/tools/clang-cc/RewriteBlocks.cpp
@@ -1091,8 +1091,9 @@
     // prototype. This enables us to rewrite function declarations and
     // definitions using the same code.
     RewriteFunctionProtoType(FD->getType(), FD);
-    
-    if (CompoundStmt *Body = FD->getBody(*Context)) {
+
+    // FIXME: Handle CXXTryStmt
+    if (CompoundStmt *Body = FD->getCompoundBody(*Context)) {
       CurFunctionDef = FD;
       FD->setBody(cast_or_null<CompoundStmt>(RewriteFunctionBody(Body)));
       // This synthesizes and inserts the block "impl" struct, invoke function,
diff --git a/tools/clang-cc/RewriteObjC.cpp b/tools/clang-cc/RewriteObjC.cpp
index 5b8fd52..95b50b8 100644
--- a/tools/clang-cc/RewriteObjC.cpp
+++ b/tools/clang-cc/RewriteObjC.cpp
@@ -980,8 +980,8 @@
     ObjCMethodDecl *OMD = *I;
     RewriteObjCMethodDecl(OMD, ResultStr);
     SourceLocation LocStart = OMD->getLocStart();
-    SourceLocation LocEnd = OMD->getBody(*Context)->getLocStart();
-    
+    SourceLocation LocEnd = OMD->getCompoundBody(*Context)->getLocStart();
+
     const char *startBuf = SM->getCharacterData(LocStart);
     const char *endBuf = SM->getCharacterData(LocEnd);
     ReplaceText(LocStart, endBuf-startBuf,
@@ -996,7 +996,7 @@
     ObjCMethodDecl *OMD = *I;
     RewriteObjCMethodDecl(OMD, ResultStr);
     SourceLocation LocStart = OMD->getLocStart();
-    SourceLocation LocEnd = OMD->getBody(*Context)->getLocStart();
+    SourceLocation LocEnd = OMD->getCompoundBody(*Context)->getLocStart();
     
     const char *startBuf = SM->getCharacterData(LocStart);
     const char *endBuf = SM->getCharacterData(LocEnd);
@@ -1426,6 +1426,7 @@
   buf += "}\n";
   
   // Insert all these *after* the statement body.
+  // FIXME: If this should support Obj-C++, support CXXTryStmt
   if (isa<CompoundStmt>(S->getBody())) {
     SourceLocation endBodyLoc = OrigEnd.getFileLocWithOffset(1);
     InsertText(endBodyLoc, buf.c_str(), buf.size());
@@ -4489,7 +4490,8 @@
     // definitions using the same code.
     RewriteBlocksInFunctionProtoType(FD->getType(), FD);
 
-    if (CompoundStmt *Body = FD->getBody(*Context)) {
+    // FIXME: If this should support Obj-C++, support CXXTryStmt
+    if (CompoundStmt *Body = FD->getCompoundBody(*Context)) {
       CurFunctionDef = FD;
       CollectPropertySetters(Body);
       CurrentBody = Body;