Fix single-line optimization for ObjC.

Puts blocks always into multiple lines when they start with an ObjC
keyword or minus.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172238 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 6beee31..a2f150d 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -405,9 +405,15 @@
 }
 
 TEST_F(FormatTest, FormatObjCTryCatch) {
-  verifyFormat("@try { f(); }\n"
-               "@catch (NSException e) { @throw; }\n"
-               "@finally { exit(42); }");
+  verifyFormat("@try {\n"
+               "  f();\n"
+               "}\n"
+               "@catch (NSException e) {\n"
+               "  @throw;\n"
+               "}\n"
+               "@finally {\n"
+               "  exit(42);\n"
+               "}");
 }
 
 TEST_F(FormatTest, StaticInitializers) {
@@ -1305,27 +1311,39 @@
                      "+(id) init;\n"
                      "@end");
 
-  verifyFormat("@interface Foo { int _i; }\n"
+  verifyFormat("@interface Foo {\n"
+               "  int _i;\n"
+               "}\n"
                "+ (id)init;\n"
                "@end");
 
-  verifyFormat("@interface Foo : Bar { int _i; }\n"
+  verifyFormat("@interface Foo : Bar {\n"
+               "  int _i;\n"
+               "}\n"
                "+ (id)init;\n"
                "@end");
 
-  verifyFormat("@interface Foo : Bar <Baz, Quux> { int _i; }\n"
+  verifyFormat("@interface Foo : Bar <Baz, Quux> {\n"
+               "  int _i;\n"
+               "}\n"
                "+ (id)init;\n"
                "@end");
 
-  verifyFormat("@interface Foo (HackStuff) { int _i; }\n"
+  verifyFormat("@interface Foo (HackStuff) {\n"
+               "  int _i;\n"
+               "}\n"
                "+ (id)init;\n"
                "@end");
 
-  verifyFormat("@interface Foo () { int _i; }\n"
+  verifyFormat("@interface Foo () {\n"
+               "  int _i;\n"
+               "}\n"
                "+ (id)init;\n"
                "@end");
 
-  verifyFormat("@interface Foo (HackStuff) <MyProtocol> { int _i; }\n"
+  verifyFormat("@interface Foo (HackStuff) <MyProtocol> {\n"
+               "  int _i;\n"
+               "}\n"
                "+ (id)init;\n"
                "@end");
 }
@@ -1363,7 +1381,9 @@
                "    return nil;\n"
                "}\n"
                "// Look, a comment!\n"
-               "- (int)answerWith:(int)i { return i; }\n"
+               "- (int)answerWith:(int)i {\n"
+               "  return i;\n"
+               "}\n"
                "@end");
 
   verifyFormat("@implementation Foo\n"
@@ -1375,11 +1395,15 @@
                "+ (id)init {}\n"
                "@end");
 
-  verifyFormat("@implementation Foo { int _i; }\n"
+  verifyFormat("@implementation Foo {\n"
+               "  int _i;\n"
+               "}\n"
                "+ (id)init {}\n"
                "@end");
 
-  verifyFormat("@implementation Foo : Bar { int _i; }\n"
+  verifyFormat("@implementation Foo : Bar {\n"
+               "  int _i;\n"
+               "}\n"
                "+ (id)init {}\n"
                "@end");
 
@@ -1469,14 +1493,18 @@
 
 TEST_F(FormatTest, ObjCSnippets) {
   // FIXME: Make the uncommented lines below pass.
-  verifyFormat("@autoreleasepool { foo(); }");
+  verifyFormat("@autoreleasepool {\n"
+               "  foo();\n"
+               "}");
   verifyFormat("@class Foo, Bar;");
   verifyFormat("@compatibility_alias AliasName ExistingClass;");
   verifyFormat("@dynamic textColor;");
   //verifyFormat("char *buf1 = @encode(int **);");
   verifyFormat("Protocol *proto = @protocol(p1);");
   //verifyFormat("SEL s = @selector(foo:);");
-  verifyFormat("@synchronized(self) { f(); }");
+  verifyFormat("@synchronized(self) {\n"
+               "  f();\n"
+               "}");
 
   verifyFormat("@synthesize dropArrowPosition = dropArrowPosition_;");
   verifyGoogleFormat("@synthesize dropArrowPosition = dropArrowPosition_;");