clang-format: Improve ObjC blocks with return type.
authorDaniel Jasper <djasper@google.com>
Sun, 23 Nov 2014 19:15:35 +0000 (19:15 +0000)
committerDaniel Jasper <djasper@google.com>
Sun, 23 Nov 2014 19:15:35 +0000 (19:15 +0000)
Before:
  Block b = ^int * (A * a, B * b) {}

After:
  Block b = ^int *(A *a, B *b) {}

This fixed llvm.org/PR21619.

llvm-svn: 222639

clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

index 346af61..a36f963 100644 (file)
@@ -1033,7 +1033,7 @@ private:
 
     // It is very unlikely that we are going to find a pointer or reference type
     // definition on the RHS of an assignment.
-    if (IsExpression)
+    if (IsExpression && !Contexts.back().CaretFound)
       return TT_BinaryOperator;
 
     return TT_PointerOrReference;
index fceebfa..58680e0 100644 (file)
@@ -9412,6 +9412,7 @@ TEST_F(FormatTest, FormatsBlocks) {
                "    }\n"
                "  }\n"
                "});");
+  verifyFormat("Block b = ^int *(A *a, B *b) {}");
 
   FormatStyle FourIndent = getLLVMStyle();
   FourIndent.ObjCBlockIndentWidth = 4;