summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-01-11 21:14:08 +0000
committerNico Weber <nicolasweber@gmx.de>2013-01-11 21:14:08 +0000
commita21aaae7b3005da690e7d7a5a481e08eb692cb93 (patch)
tree28c8aeb74f409b4048e91edf81601d7852ed9601 /clang
parent7a7284d881b0cf5f0729db461d8df06ef32e76a5 (diff)
downloadbcm5719-llvm-a21aaae7b3005da690e7d7a5a481e08eb692cb93.tar.gz
bcm5719-llvm-a21aaae7b3005da690e7d7a5a481e08eb692cb93.zip
Formatter: Format ObjC static and instance methods consistently, add a test for that.
llvm-svn: 172254
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/Format.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp4
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index cee587bf323..77fba1fbf1c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -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))
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index a0cfeee90b4..2c1c9ee659f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -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"
OpenPOWER on IntegriCloud