From: Daniel Jasper Date: Sun, 23 Nov 2014 19:15:35 +0000 (+0000) Subject: clang-format: Improve ObjC blocks with return type. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c26dc84ec1413a4250ff76307ef430959ad3a969;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222639 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 346af61199..a36f9630e6 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index fceebfadea..58680e0734 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -9412,6 +9412,7 @@ TEST_F(FormatTest, FormatsBlocks) { " }\n" " }\n" "});"); + verifyFormat("Block b = ^int *(A *a, B *b) {}"); FormatStyle FourIndent = getLLVMStyle(); FourIndent.ObjCBlockIndentWidth = 4;