]> granicus.if.org Git - clang/commitdiff
Formatter: Format ObjC static and instance methods consistently, add a test for that.
authorNico Weber <nicolasweber@gmx.de>
Fri, 11 Jan 2013 21:14:08 +0000 (21:14 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 11 Jan 2013 21:14:08 +0000 (21:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172254 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp
unittests/Format/FormatTest.cpp

index cee587bf32364baacdc34a91a5b6421534bf9bbc..77fba1fbf1ca0111e67508e7633a1b5e3e956e03 100644 (file)
@@ -1342,8 +1342,9 @@ private:
         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))
index a0cfeee90b48af66058eeef8ae2306240058490b..2c1c9ee659f40ad642d028ff834a21deaeba0929 100644 (file)
@@ -1388,6 +1388,9 @@ TEST_F(FormatTest, FormatObjCImplementation) {
                "- (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 @@ TEST_F(FormatTest, FormatObjCImplementation) {
 
   verifyFormat("@implementation Foo : Bar\n"
                "+ (id)init {}\n"
+               "- (void)foo {}\n"
                "@end");
 
   verifyFormat("@implementation Foo {\n"