]> granicus.if.org Git - clang/commitdiff
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222639 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 346af61199c8d9eb6f226826cf90667b5a625d40..a36f9630e6860a011fa73beb430c7adeb8b2bedc 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 fceebfadea76f382fa81c1942f9007e5812212d7..58680e073438e6d79a25e10b0dde9f6bdfc825e5 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;