summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-04-08 14:04:31 +0000
committerDaniel Jasper <djasper@google.com>2014-04-08 14:04:31 +0000
commitb77105d2cef9017a0348b99c08a90dec1354082b (patch)
treecd0b591913cfbe4c69593106c989020ca242d951 /clang
parent50996ce1e332334f3fa1913e90992e1128a5abaf (diff)
downloadbcm5719-llvm-b77105d2cef9017a0348b99c08a90dec1354082b.tar.gz
bcm5719-llvm-b77105d2cef9017a0348b99c08a90dec1354082b.zip
clang-format: Fix incorrect multi-block-parameter computation.
llvm-svn: 205763
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp6
2 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index f890af33deb..a7536d2d244 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index c7bd44c12d2..975f9c6939b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/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"
OpenPOWER on IntegriCloud