Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -800,8 +800,9 @@ FormatStyle::BCIS_AfterColon) { CurrentState.Indent = State.Column; CurrentState.LastSpace = State.Column; - } else if ((Previous.isOneOf(TT_BinaryOperator, TT_ConditionalExpr, - TT_CtorInitializerColon)) && + } else if (Previous.is(TT_CtorInitializerColon)) { + CurrentState.LastSpace = State.Column; + } else if ((Previous.isOneOf(TT_BinaryOperator, TT_ConditionalExpr)) && ((Previous.getPrecedence() != prec::Assignment && (Previous.isNot(tok::lessless) || Previous.OperatorIndex != 0 || Previous.NextOperator)) || @@ -809,8 +810,10 @@ // Indent relative to the RHS of the expression unless this is a simple // assignment without binary expression on the RHS. Also indent relative to // unary operators and the colons of constructor initializers. - if (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None) + if (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None || + Style.BreakBeforeBinaryOperators == FormatStyle::BOS_NonAssignment) { CurrentState.LastSpace = State.Column; + } } else if (Previous.is(TT_InheritanceColon)) { CurrentState.Indent = State.Column; CurrentState.LastSpace = State.Column; Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -6594,6 +6594,25 @@ "(someOtherLongishConditionPart1 || " "someOtherEvenLongerNestedConditionPart2);", Style)); + + Style = getLLVMStyle(); + Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; + Style.BinPackParameters = false; + Style.ContinuationIndentWidth = 2; + Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment; + verifyFormat( + "struct Derived {\n" + " Derived(\n" + " int firstArgWithLongName,\n" + " int secondArgWithLongName,\n" + " int thirdArgWithLongName,\n" + " int fourthArgWithLongName)\n" + " : Base(\n" + " firstArgWithLongName,\n" + " secondArgWithLongName,\n" + " thirdArgWithLongName,\n" + " fourthArgWithLongName) {}\n" + "};", Style); } TEST_F(FormatTest, ExpressionIndentationStrictAlign) {