aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/Format.cpp4
-rw-r--r--unittests/Format/FormatTest.cpp6
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index c5e1052ce9..a847d4ef9b 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -406,7 +406,9 @@ private:
for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i) {
State.Stack[i].BreakBeforeParameter = true;
}
- if (Current.isOneOf(tok::period, tok::arrow))
+ const AnnotatedToken *TokenBefore = Current.getPreviousNoneComment();
+ if (TokenBefore && !TokenBefore->isOneOf(tok::comma, tok::semi) &&
+ !TokenBefore->opensScope())
State.Stack.back().BreakBeforeParameter = true;
// If we break after {, we should also break before the corresponding }.
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index cbf5cf98b0..ff277156e3 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1740,6 +1740,12 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
" Cccccccccccccc cccccccccc, Cccccccccccccc cccccccccc,\n"
" Cccccccccccccc cccccccccc, Cccccccccccccc cccccccccc,\n"
" Cccccccccccccc cccccccccc, Cccccccccccccc cccccccccc);");
+
+ // Break after multi-line parameters.
+ verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " bbbb bbbb);");
}
TEST_F(FormatTest, BreaksDesireably) {