r222639 - clang-format: Improve ObjC blocks with return type.

Daniel Jasper djasper at google.com
Sun Nov 23 11:15:36 PST 2014


Author: djasper
Date: Sun Nov 23 13:15:35 2014
New Revision: 222639

URL: http://llvm.org/viewvc/llvm-project?rev=222639&view=rev
Log:
clang-format: Improve ObjC blocks with return type.

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

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

This fixed llvm.org/PR21619.

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=222639&r1=222638&r2=222639&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sun Nov 23 13:15:35 2014
@@ -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;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=222639&r1=222638&r2=222639&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sun Nov 23 13:15:35 2014
@@ -9412,6 +9412,7 @@ TEST_F(FormatTest, FormatsBlocks) {
                "    }\n"
                "  }\n"
                "});");
+  verifyFormat("Block b = ^int *(A *a, B *b) {}");
 
   FormatStyle FourIndent = getLLVMStyle();
   FourIndent.ObjCBlockIndentWidth = 4;





More information about the cfe-commits mailing list