r257257 - clang-format: Fix incorrect line break in certain configurations.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 9 07:56:47 PST 2016
Author: djasper
Date: Sat Jan 9 09:56:47 2016
New Revision: 257257
URL: http://llvm.org/viewvc/llvm-project?rev=257257&view=rev
Log:
clang-format: Fix incorrect line break in certain configurations.
Before:
void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
vector<int>
bbbbbbbbbbbbbbb);
After:
void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
vector<int> bbbbbbbbbbbbbbb);
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=257257&r1=257256&r2=257257&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Sat Jan 9 09:56:47 2016
@@ -150,7 +150,8 @@ bool ContinuationIndenter::mustBreak(con
if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
return true;
if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
- (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName)) ||
+ (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
+ Previous.NestingLevel == 1) ||
(Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
Previous.isNot(tok::question)) ||
(!Style.BreakBeforeTernaryOperators &&
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=257257&r1=257256&r2=257257&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sat Jan 9 09:56:47 2016
@@ -4062,6 +4062,10 @@ TEST_F(FormatTest, FormatsDeclarationsOn
" int aaaaaaaaaaaaaaaaaaaa,\n"
" int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}",
NoBinPacking);
+ NoBinPacking.AllowAllParametersOfDeclarationOnNextLine = false;
+ verifyFormat("void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " vector<int> bbbbbbbbbbbbbbb);",
+ NoBinPacking);
}
TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) {
More information about the cfe-commits
mailing list