summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-05-14 20:39:56 +0000
committerDaniel Jasper <djasper@google.com>2013-05-14 20:39:56 +0000
commitd741f02da9c91c197ba8816b4b454e1ad7cd47b6 (patch)
tree6ec6e3dc3bf8fb84a3c6092d5c20bbbd848af87d
parent6e01994046860c5c120c832a22557ec1c6b72ce9 (diff)
downloadclang-d741f02da9c91c197ba8816b4b454e1ad7cd47b6.tar.gz
clang-d741f02da9c91c197ba8816b4b454e1ad7cd47b6.tar.bz2
clang-d741f02da9c91c197ba8816b4b454e1ad7cd47b6.tar.xz
Fix expression breaking for one-parameter-per-line styles.
Before: if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} After: if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181828 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Format/Format.cpp3
-rw-r--r--unittests/Format/FormatTest.cpp8
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 5cb5fef9d5..e85ecd21c2 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -543,7 +543,8 @@ private:
if (State.Stack.back().AvoidBinPacking) {
// If we are breaking after '(', '{', '<', this is not bin packing
// unless AllowAllParametersOfDeclarationOnNextLine is false.
- if ((Previous.isNot(tok::l_paren) && Previous.isNot(tok::l_brace)) ||
+ if (!(Previous.isOneOf(tok::l_paren, tok::l_brace) ||
+ Previous.Type == TT_BinaryOperator) ||
(!Style.AllowAllParametersOfDeclarationOnNextLine &&
Line.MustBeDeclaration))
State.Stack.back().BreakBeforeParameter = true;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 665f20322e..206343bb69 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1646,6 +1646,14 @@ TEST_F(FormatTest, LineBreakingInBinaryExpressions) {
" SourceMgr.getSpellingColumnNumber(\n"
" TheLine.Last->FormatTok.Tok.getLocation()) -\n"
" 1);");
+
+ FormatStyle OnePerLine = getLLVMStyle();
+ OnePerLine.BinPackParameters = false;
+ verifyFormat(
+ "if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}",
+ OnePerLine);
}
TEST_F(FormatTest, ExpressionIndentation) {