]> granicus.if.org Git - clang/commitdiff
Rewrite of forward protocol declaration.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 14 Nov 2007 00:42:16 +0000 (00:42 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 14 Nov 2007 00:42:16 +0000 (00:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44095 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteTest.cpp

index 9e17a6ef8cd64e0fd8b5392ef7412d9aa6fb05b4..cd1e994bbfe8b04b3207ae270c8ed1c31d95dce0 100644 (file)
@@ -91,6 +91,7 @@ namespace {
     void RewriteObjcMethodDecl(ObjcMethodDecl *MDecl, std::string &ResultStr);
     void RewriteCategoryDecl(ObjcCategoryDecl *Dcl);
     void RewriteProtocolDecl(ObjcProtocolDecl *Dcl);
+    void RewriteForwardProtocolDecl(ObjcForwardProtocolDecl *Dcl);
     void RewriteMethodDeclarations(int nMethods, ObjcMethodDecl **Methods);
     void RewriteProperties(int nProperties, ObjcPropertyDecl **Properties);
     void RewriteFunctionDecl(FunctionDecl *FD);
@@ -173,6 +174,9 @@ void RewriteTest::HandleTopLevelDecl(Decl *D) {
     RewriteCategoryDecl(CD);
   } else if (ObjcProtocolDecl *PD = dyn_cast<ObjcProtocolDecl>(D)) {
     RewriteProtocolDecl(PD);
+  } else if (ObjcForwardProtocolDecl *FP = 
+             dyn_cast<ObjcForwardProtocolDecl>(D)){
+    RewriteForwardProtocolDecl(FP);
   }
   // If we have a decl in the main file, see if we should rewrite it.
   if (SM->getDecomposedFileLoc(Loc).first == MainFileID)
@@ -380,6 +384,12 @@ void RewriteTest::RewriteProtocolDecl(ObjcProtocolDecl *PDecl) {
   Rewrite.ReplaceText(PDecl->getAtEndLoc(), 0, "// ", 3);
 }
 
+void RewriteTest::RewriteForwardProtocolDecl(ObjcForwardProtocolDecl *PDecl) {
+  SourceLocation LocStart = PDecl->getLocation();
+  // FIXME: handle forward protocol that are declared across multiple lines.
+  Rewrite.ReplaceText(LocStart, 0, "// ", 3);
+}
+
 void RewriteTest::RewriteObjcMethodDecl(ObjcMethodDecl *OMD, 
                                         std::string &ResultStr) {
   static bool includeObjc = false;