diff options
author | Daniel Jasper <djasper@google.com> | 2017-05-08 15:07:52 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2017-05-08 15:07:52 +0000 |
commit | c7b6c9527a4ed79fee5bba10a0afb2215a9cbb27 (patch) | |
tree | ace5c66a91a8c2fb17b4b419f55fbf4de203a057 /unittests/Format/FormatTest.cpp | |
parent | 060a901b177158ae36172ad10e7d7f933d1fa06a (diff) |
[clang-format] Don’t propagate AvoidBinPacking into argument
subexpressions
This is an attempt to fix the issue described in a recent email:
http://lists.llvm.org/pipermail/cfe-dev/2017-April/053632.html
Patch by jtbandes. Thank you!
Review: https://reviews.llvm.org/D32475
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302427 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 9b833a96f1..34faa17b1c 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2591,6 +2591,60 @@ TEST_F(FormatTest, BreakingBeforeNonAssigmentOperators) { Style); } +TEST_F(FormatTest, AllowBinPackingInsideArguments) { + FormatStyle Style = getLLVMStyle(); + Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment; + Style.BinPackArguments = false; + Style.ColumnLimit = 40; + verifyFormat("void test() {\n" + " someFunction(\n" + " this + argument + is + quite\n" + " + long + so + it + gets + wrapped\n" + " + but + remains + bin - packed);\n" + "}", + Style); + verifyFormat("void test() {\n" + " someFunction(arg1,\n" + " this + argument + is\n" + " + quite + long + so\n" + " + it + gets + wrapped\n" + " + but + remains + bin\n" + " - packed,\n" + " arg3);\n" + "}", + Style); + verifyFormat("void test() {\n" + " someFunction(\n" + " arg1,\n" + " this + argument + has\n" + " + anotherFunc(nested,\n" + " calls + whose\n" + " + arguments\n" + " + are + also\n" + " + wrapped,\n" + " in + addition)\n" + " + to + being + bin - packed,\n" + " arg3);\n" + "}", + Style); + + Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None; + verifyFormat("void test() {\n" + " someFunction(\n" + " arg1,\n" + " this + argument + has +\n" + " anotherFunc(nested,\n" + " calls + whose +\n" + " arguments +\n" + " are + also +\n" + " wrapped,\n" + " in + addition) +\n" + " to + being + bin - packed,\n" + " arg3);\n" + "}", + Style); +} + TEST_F(FormatTest, ConstructorInitializers) { verifyFormat("Constructor() : Initializer(FitsOnTheLine) {}"); verifyFormat("Constructor() : Inttializer(FitsOnTheLine) {}", |