diff options
author | Daniel Jasper <djasper@google.com> | 2013-05-14 20:39:56 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-05-14 20:39:56 +0000 |
commit | d741f02da9c91c197ba8816b4b454e1ad7cd47b6 (patch) | |
tree | 6ec6e3dc3bf8fb84a3c6092d5c20bbbd848af87d | |
parent | 6e01994046860c5c120c832a22557ec1c6b72ce9 (diff) | |
download | clang-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.cpp | 3 | ||||
-rw-r--r-- | unittests/Format/FormatTest.cpp | 8 |
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) { |