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 | 571f1af0bb658b36ec068ca9ec2c627568a4ce30 (patch) | |
| tree | a501a94b53748d8066e23d10bbe7f26cabeaa7dd | |
| parent | 91a1b2c9ebfc8a707a2ef8f9b6d31ed3c478958a (diff) | |
| download | bcm5719-llvm-571f1af0bb658b36ec068ca9ec2c627568a4ce30.tar.gz bcm5719-llvm-571f1af0bb658b36ec068ca9ec2c627568a4ce30.zip | |
Fix expression breaking for one-parameter-per-line styles.
Before:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
After:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
llvm-svn: 181828
| -rw-r--r-- | clang/lib/Format/Format.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 5cb5fef9d54..e85ecd21c2e 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 665f20322eb..206343bb690 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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) { |

