r288119 - clang-format: Fix unnnecessary line break.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 29 01:40:01 PST 2016
Author: djasper
Date: Tue Nov 29 03:40:01 2016
New Revision: 288119
URL: http://llvm.org/viewvc/llvm-project?rev=288119&view=rev
Log:
clang-format: Fix unnnecessary line break.
Before:
aaaaaaaaaa(aaaa(aaaa,
aaaa), //
aaaa,
aaaaa);
After:
aaaaaaaaaa(aaaa(aaaa,
aaaa), //
aaaa, aaaaa);
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=288119&r1=288118&r2=288119&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Nov 29 03:40:01 2016
@@ -523,7 +523,8 @@ unsigned ContinuationIndenter::addTokenO
Style.ContinuationIndentWidth;
}
- if ((Previous.isOneOf(tok::comma, tok::semi) &&
+ if ((PreviousNonComment &&
+ PreviousNonComment->isOneOf(tok::comma, tok::semi) &&
!State.Stack.back().AvoidBinPacking) ||
Previous.is(TT_BinaryOperator))
State.Stack.back().BreakBeforeParameter = false;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=288119&r1=288118&r2=288119&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Nov 29 03:40:01 2016
@@ -1137,6 +1137,12 @@ TEST_F(FormatTest, KeepsParameterWithTra
format("SomeFunction(a, // comment\n"
" b,\n"
" c); // comment"));
+ EXPECT_EQ("aaaaaaaaaa(aaaa(aaaa,\n"
+ " aaaa), //\n"
+ " aaaa, bbbbb);",
+ format("aaaaaaaaaa(aaaa(aaaa,\n"
+ "aaaa), //\n"
+ "aaaa, bbbbb);"));
}
TEST_F(FormatTest, RemovesTrailingWhitespaceOfComments) {
More information about the cfe-commits
mailing list