Rewrite method definition bodies. Also renamed a method to distinguish between method declarations and definitions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44080 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index ff9bf2f..9e17a6e 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -91,7 +91,7 @@
     void RewriteObjcMethodDecl(ObjcMethodDecl *MDecl, std::string &ResultStr);
     void RewriteCategoryDecl(ObjcCategoryDecl *Dcl);
     void RewriteProtocolDecl(ObjcProtocolDecl *Dcl);
-    void RewriteMethods(int nMethods, ObjcMethodDecl **Methods);
+    void RewriteMethodDeclarations(int nMethods, ObjcMethodDecl **Methods);
     void RewriteProperties(int nProperties, ObjcPropertyDecl **Properties);
     void RewriteFunctionDecl(FunctionDecl *FD);
     void RewriteObjcQualifiedInterfaceTypes(
@@ -189,7 +189,11 @@
   if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
     if (Stmt *Body = FD->getBody())
       FD->setBody(RewriteFunctionBodyOrGlobalInitializer(Body));
-  
+	  
+  if (ObjcMethodDecl *MD = dyn_cast<ObjcMethodDecl>(D)) {
+    if (Stmt *Body = MD->getBody())
+      MD->setBody(RewriteFunctionBodyOrGlobalInitializer(Body));
+  }
   if (ObjcImplementationDecl *CI = dyn_cast<ObjcImplementationDecl>(D))
     ClassImplementation.push_back(CI);
   else if (ObjcCategoryImplDecl *CI = dyn_cast<ObjcCategoryImplDecl>(D))
@@ -325,7 +329,7 @@
                       typedefString.c_str(), typedefString.size());
 }
 
-void RewriteTest::RewriteMethods(int nMethods, ObjcMethodDecl **Methods) {
+void RewriteTest::RewriteMethodDeclarations(int nMethods, ObjcMethodDecl **Methods) {
   for (int i = 0; i < nMethods; i++) {
     ObjcMethodDecl *Method = Methods[i];
     SourceLocation Loc = Method->getLocStart();
@@ -354,10 +358,10 @@
   // FIXME: handle category headers that are declared across multiple lines.
   Rewrite.ReplaceText(LocStart, 0, "// ", 3);
   
-  RewriteMethods(CatDecl->getNumInstanceMethods(),
-                 CatDecl->getInstanceMethods());
-  RewriteMethods(CatDecl->getNumClassMethods(),
-                 CatDecl->getClassMethods());
+  RewriteMethodDeclarations(CatDecl->getNumInstanceMethods(),
+                            CatDecl->getInstanceMethods());
+  RewriteMethodDeclarations(CatDecl->getNumClassMethods(),
+                            CatDecl->getClassMethods());
   // Lastly, comment out the @end.
   Rewrite.ReplaceText(CatDecl->getAtEndLoc(), 0, "// ", 3);
 }
@@ -368,10 +372,10 @@
   // FIXME: handle protocol headers that are declared across multiple lines.
   Rewrite.ReplaceText(LocStart, 0, "// ", 3);
   
-  RewriteMethods(PDecl->getNumInstanceMethods(),
-                 PDecl->getInstanceMethods());
-  RewriteMethods(PDecl->getNumClassMethods(),
-                 PDecl->getClassMethods());
+  RewriteMethodDeclarations(PDecl->getNumInstanceMethods(),
+                            PDecl->getInstanceMethods());
+  RewriteMethodDeclarations(PDecl->getNumClassMethods(),
+                            PDecl->getClassMethods());
   // Lastly, comment out the @end.
   Rewrite.ReplaceText(PDecl->getAtEndLoc(), 0, "// ", 3);
 }
@@ -533,10 +537,10 @@
                       ResultStr.c_str(), ResultStr.size());
   RewriteProperties(ClassDecl->getNumPropertyDecl(),
                     ClassDecl->getPropertyDecl());
-  RewriteMethods(ClassDecl->getNumInstanceMethods(),
-                 ClassDecl->getInstanceMethods());
-  RewriteMethods(ClassDecl->getNumClassMethods(),
-                 ClassDecl->getClassMethods());
+  RewriteMethodDeclarations(ClassDecl->getNumInstanceMethods(),
+                            ClassDecl->getInstanceMethods());
+  RewriteMethodDeclarations(ClassDecl->getNumClassMethods(),
+                            ClassDecl->getClassMethods());
   
   // Lastly, comment out the @end.
   Rewrite.ReplaceText(ClassDecl->getAtEndLoc(), 0, "// ", 3);