]> granicus.if.org Git - clang/commitdiff
Rewrite methods that span multiple lines.
authorSteve Naroff <snaroff@apple.com>
Wed, 14 Nov 2007 14:34:23 +0000 (14:34 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 14 Nov 2007 14:34:23 +0000 (14:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44118 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteTest.cpp

index 78cd90e9a91f266dd520f107919dd2ad7a1a7679..283f3602346e6826ee331164aa506e728189b4bd 100644 (file)
@@ -336,11 +336,15 @@ void RewriteTest::RewriteForwardClassDecl(ObjcClassDecl *ClassDecl) {
 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);
+    }
   }
 }