Fix ObjC block declarations.

Before: int ( ^ Block1) (int, int) = ^ (int i, int j)
After:  int (^Block1) (int, int) = ^(int i, int j)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171959 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index e8c6210..16e8c2d 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -846,8 +846,9 @@
     if (Current.Type == TT_Unknown) {
       if (Current.is(tok::star) || Current.is(tok::amp)) {
         Current.Type = determineStarAmpUsage(Current, IsRHS);
-      } else if (Current.is(tok::minus) || Current.is(tok::plus)) {
-        Current.Type = determinePlusMinusUsage(Current);
+      } else if (Current.is(tok::minus) || Current.is(tok::plus) ||
+                 Current.is(tok::caret)) {
+        Current.Type = determinePlusMinusCaretUsage(Current);
       } else if (Current.is(tok::minusminus) || Current.is(tok::plusplus)) {
         Current.Type = determineIncrementUsage(Current);
       } else if (Current.is(tok::exclaim)) {
@@ -905,7 +906,7 @@
     return TT_PointerOrReference;
   }
 
-  TokenType determinePlusMinusUsage(const AnnotatedToken &Tok) {
+  TokenType determinePlusMinusCaretUsage(const AnnotatedToken &Tok) {
     // At the start of the line, +/- specific ObjectiveC method declarations.
     if (Tok.Parent == NULL)
       return TT_ObjCMethodSpecifier;
diff --git a/test/Index/comment-c-decls.c b/test/Index/comment-c-decls.c
index be45ee2..f6d3fee 100644
--- a/test/Index/comment-c-decls.c
+++ b/test/Index/comment-c-decls.c
@@ -95,10 +95,10 @@
  *\brief block declaration
 */
 int (^Block) (int i, int j);
-// CHECK: <Declaration>int ( ^ Block) (int, int)</Declaration>
+// CHECK: <Declaration>int (^Block) (int, int)</Declaration>
 
 /**
  *\brief block declaration
 */
 int (^Block1) (int i, int j) = ^(int i, int j) { return i + j; };
-// CHECK: <Declaration>int ( ^ Block1) (int, int) = ^ (int i, int j) {\n}</Declaration>
+// CHECK: <Declaration>int (^Block1) (int, int) = ^(int i, int j) {\n}</Declaration>
diff --git a/test/Index/format-comment-cdecls.c b/test/Index/format-comment-cdecls.c
index b1539fe..31ec95b 100644
--- a/test/Index/format-comment-cdecls.c
+++ b/test/Index/format-comment-cdecls.c
@@ -90,10 +90,10 @@
  *\brief block declaration
 */
 int (^Block) (int i, int j);
-// CHECK: <Declaration>int ( ^ Block) (int, int)</Declaration>
+// CHECK: <Declaration>int (^Block) (int, int)</Declaration>
 
 /**
  *\brief block declaration
 */
 int (^Block1) (int i, int j) = ^(int i, int j) { return i + j; };
-// CHECK: <Declaration>int ( ^ Block1) (int, int) = ^ (int i, int j) {\n}</Declaration>
+// CHECK: <Declaration>int (^Block1) (int, int) = ^(int i, int j) {\n}</Declaration>
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 9bf3097..2e6424d 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1122,6 +1122,11 @@
           "outRange8:(NSRange) out_range8  outRange9:(NSRange) out_range9;"));
 }
 
+TEST_F(FormatTest, FormatObjCBlocks) {
+  verifyFormat("int (^Block) (int, int);");
+  verifyFormat("int (^Block1) (int, int) = ^(int i, int j)");
+}
+
 TEST_F(FormatTest, ObjCAt) {
   verifyFormat("@autoreleasepool");
   verifyFormat("@catch");