[cfe-commits] r44118 - /cfe/trunk/Driver/RewriteTest.cpp

Steve Naroff snaroff at apple.com
Wed Nov 14 06:34:26 PST 2007


Author: snaroff
Date: Wed Nov 14 08:34:23 2007
New Revision: 44118

URL: http://llvm.org/viewvc/llvm-project?rev=44118&view=rev
Log:

Rewrite methods that span multiple lines.


Modified:
    cfe/trunk/Driver/RewriteTest.cpp

Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44118&r1=44117&r2=44118&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Wed Nov 14 08:34:23 2007
@@ -336,11 +336,15 @@
 void RewriteTest::RewriteMethodDeclarations(int nMethods, ObjcMethodDecl **Methods) {
   for (int i = 0; i < nMethods; i++) {
     ObjcMethodDecl *Method = Methods[i];
-    SourceLocation Loc = Method->getLocStart();
-
-    Rewrite.InsertText(Loc, "// ", 3);
+    SourceLocation LocStart = Method->getLocStart();
+    SourceLocation LocEnd = Method->getLocEnd();
     
-    // FIXME: handle methods that are declared across multiple lines.
+    if (SM->getLineNumber(LocEnd) > SM->getLineNumber(LocStart)) {
+      Rewrite.InsertText(LocStart, "/* ", 3);
+      Rewrite.ReplaceText(LocEnd, 1, ";*/ ", 4);
+    } else {
+      Rewrite.InsertText(LocStart, "// ", 3);
+    }
   }
 }
 





More information about the cfe-commits mailing list