diff options
| -rw-r--r-- | clang/lib/Format/Format.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index a6a53f48fd8..27d47109bd8 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -625,7 +625,8 @@ private: // Top-level spaces are exempt as that mostly leads to better results. State.Stack.back().LastSpace = State.Column; else if ((Previous.Type == TT_BinaryOperator || - Previous.Type == TT_ConditionalExpr) && + Previous.Type == TT_ConditionalExpr || + Previous.Type == TT_CtorInitializerColon) && getPrecedence(Previous) != prec::Assignment) State.Stack.back().LastSpace = State.Column; else if (Previous.ParameterCount > 1 && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index c1430193eb6..417dc9e9a24 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -924,6 +924,10 @@ TEST_F(FormatTest, ConstructorInitializers) { " aaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" " aaaaaaaaaaaaaaaaaaaaaaa() {\n}"); + verifyFormat("Constructor()\n" + " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}"); + // Here a line could be saved by splitting the second initializer onto two // lines, but that is not desireable. verifyFormat( |

