aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/Format.cpp4
-rw-r--r--lib/Format/TokenAnnotator.cpp2
-rw-r--r--unittests/Format/FormatTest.cpp6
3 files changed, 8 insertions, 4 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 0e4a2b797f..1a7dbe0936 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -372,8 +372,8 @@ private:
void alignComments(comment_iterator I, comment_iterator E, unsigned Column) {
while (I != E) {
unsigned Spaces = I->Spaces + Column - I->MinColumn;
- storeReplacement(I->Tok, std::string(I->NewLines, '\n') +
- std::string(Spaces, ' '));
+ storeReplacement(
+ I->Tok, std::string(I->NewLines, '\n') + std::string(Spaces, ' '));
++I;
}
}
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index c2b6c1b3e4..7c4797978f 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -937,7 +937,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return 20;
if (opensScope(Left))
- return 20;
+ return Left.ParameterCount > 1 ? prec::Comma : 20;
if (Right.is(tok::lessless)) {
if (Left.is(tok::string_literal)) {
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 6de861aa3c..7f9cecb031 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1485,6 +1485,10 @@ TEST_F(FormatTest, BreaksDesireably) {
verifyFormat(
"aaaaaa(aaa, new Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaa));");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
// This test case breaks on an incorrect memoization, i.e. an optimization not
// taking into account the StopAt value.
@@ -1677,7 +1681,7 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
" : aaaaaaaaaaaaa);");
verifyFormat(
"aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa,\n"
- " aaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaa\n"
+ " aaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" : aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaa);");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"