[PATCH] D46824: [clang-format] Continue after non-scope-closers in getLengthToMatchingParen
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 14 03:28:17 PDT 2018
krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.
This fixes a regression introduced by `r331857` where we stop the search for
the End token as soon as we hit a non-scope-closer, which prematurely stops before
semicolons for example, which should otherwise be considered as part of the unbreakable tail.
Repository:
rC Clang
https://reviews.llvm.org/D46824
Files:
lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTestObjC.cpp
Index: unittests/Format/FormatTestObjC.cpp
===================================================================
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -1142,6 +1142,18 @@
" @\"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n"
"];\n");
}
+
+TEST_F(FormatTestObjC, BreaksCallStatementWhereSemiJustOverTheLimit) {
+ Style.ColumnLimit = 60;
+ // If the statement starting with 'a = ...' is put on a single line, the ';'
+ // is at line 61.
+ verifyFormat("int f(int a) {\n"
+ " a = [self aaaaaaaaaa:bbbbbbbbb\n"
+ " ccccccccc:dddddddd\n"
+ " ee:fddd];\n"
+ "}");
+}
+
} // end namespace
} // end namespace format
} // end namespace clang
Index: lib/Format/ContinuationIndenter.cpp
===================================================================
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -90,8 +90,10 @@
return MatchingStackIndex >= 0 ? &Stack[MatchingStackIndex] : nullptr;
};
for (; End->Next; End = End->Next) {
- if (End->Next->CanBreakBefore || !End->Next->closesScope())
+ if (End->Next->CanBreakBefore)
break;
+ if (!End->Next->closesScope())
+ continue;
if (End->Next->MatchingParen->isOneOf(tok::l_brace,
TT_ArrayInitializerLSquare,
tok::less)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46824.146569.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180514/4744c42c/attachment.bin>
More information about the cfe-commits
mailing list