diff options
author | Steve Naroff <snaroff@apple.com> | 2007-11-13 23:01:27 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-11-13 23:01:27 +0000 |
commit | 71c0a951d08dc7a2a057df8c15f22b36f6aa47c7 (patch) | |
tree | 86eb4af5d5491185106ac32372281fe1c3a11a89 /Driver/RewriteTest.cpp | |
parent | 950ba9cc6aaa508381fbf56224c68d2da81caa4b (diff) |
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
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r-- | Driver/RewriteTest.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index ff9bf2f924..9e17a6ef8c 100644 --- a/Driver/RewriteTest.cpp +++ b/Driver/RewriteTest.cpp @@ -91,7 +91,7 @@ namespace { 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 @@ void RewriteTest::HandleDeclInMainFile(Decl *D) { 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 @@ void RewriteTest::RewriteForwardClassDecl(ObjcClassDecl *ClassDecl) { 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 @@ void RewriteTest::RewriteCategoryDecl(ObjcCategoryDecl *CatDecl) { // 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 @@ void RewriteTest::RewriteProtocolDecl(ObjcProtocolDecl *PDecl) { // 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 @@ void RewriteTest::RewriteInterfaceDecl(ObjcInterfaceDecl *ClassDecl) { 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); |