[cfe-commits] r172254 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp

Nico Weber nicolasweber at gmx.de
Fri Jan 11 13:14:08 PST 2013


Author: nico
Date: Fri Jan 11 15:14:08 2013
New Revision: 172254

URL: http://llvm.org/viewvc/llvm-project?rev=172254&view=rev
Log:
Formatter: Format ObjC static and instance methods consistently, add a test for that.

Modified:
    cfe/trunk/lib/Format/Format.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172254&r1=172253&r2=172254&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jan 11 15:14:08 2013
@@ -1342,8 +1342,9 @@
         Last->Tok.isNot(tok::kw_do) && Last->Tok.isNot(tok::r_brace) &&
         Last->Tok.isNot(tok::kw_else) && Last->Tok.isNot(tok::kw_try) &&
         Last->Tok.isNot(tok::kw_catch) && Last->Tok.isNot(tok::kw_for) &&
-        // This gets rid of all ObjC @ keywords and - based definitions.
-        Last->Tok.isNot(tok::at) && Last->Tok.isNot(tok::minus);
+        // This gets rid of all ObjC @ keywords and methods.
+        Last->Tok.isNot(tok::at) && Last->Tok.isNot(tok::minus) &&
+        Last->Tok.isNot(tok::plus);
     while (!Last->Children.empty())
       Last = &Last->Children.back();
     if (!Last->Tok.is(tok::l_brace))

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172254&r1=172253&r2=172254&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jan 11 15:14:08 2013
@@ -1388,6 +1388,9 @@
                "- (int)answerWith:(int)i {\n"
                "  return i;\n"
                "}\n"
+               "+ (int)answerWith:(int)i {\n"
+               "  return i;\n"
+               "}\n"
                "@end");
 
   verifyFormat("@implementation Foo\n"
@@ -1397,6 +1400,7 @@
 
   verifyFormat("@implementation Foo : Bar\n"
                "+ (id)init {}\n"
+               "- (void)foo {}\n"
                "@end");
 
   verifyFormat("@implementation Foo {\n"





More information about the cfe-commits mailing list