From d220c37e06c00e0c7dfa5ea68c7090354d6498b5 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 8 Apr 2014 14:04:31 +0000 Subject: [PATCH] clang-format: Fix incorrect multi-block-parameter computation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205763 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 5 ++--- unittests/Format/FormatTest.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index f890af33de..a7536d2d24 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -727,10 +727,9 @@ private: Contexts.back().InTemplateArgument); } else if (Current.isOneOf(tok::minus, tok::plus, tok::caret)) { Current.Type = determinePlusMinusCaretUsage(Current); - if (Current.Type == TT_UnaryOperator) { + if (Current.Type == TT_UnaryOperator && Current.is(tok::caret)) { ++Contexts.back().NumBlockParameters; - if (Current.is(tok::caret)) - Contexts.back().CaretFound = true; + Contexts.back().CaretFound = true; } } else if (Current.isOneOf(tok::minusminus, tok::plusplus)) { Current.Type = determineIncrementUsage(Current); diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index c7bd44c12d..975f9c6939 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -8249,6 +8249,12 @@ TEST_F(FormatTest, FormatsBlocks) { " // ...\n" " int i;\n" " }];"); + verifyFormat("[myObject doSomethingWith:arg1\n" + " firstBlock:-1\n" + " secondBlock:^(Bar *b) {\n" + " // ...\n" + " int i;\n" + " }];"); verifyFormat("f(^{\n" " @autoreleasepool {\n" -- 2.40.0