Author: krasimir Date: Mon May 14 03:33:40 2018 New Revision: 332225 URL: http://llvm.org/viewvc/llvm-project?rev=332225&view=rev Log: [clang-format] Continue after non-scope-closers in getLengthToMatchingParen
Summary: 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. Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D46824 Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/unittests/Format/FormatTestObjC.cpp Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=332225&r1=332224&r2=332225&view=diff ============================================================================== --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon May 14 03:33:40 2018 @@ -90,8 +90,10 @@ static unsigned getLengthToMatchingParen 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)) { Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=332225&r1=332224&r2=332225&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Mon May 14 03:33:40 2018 @@ -1142,6 +1142,18 @@ TEST_F(FormatTestObjC, ObjCArrayLiterals " @\"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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits