summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp12
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 0c202565051..f035aa71e5a 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -700,7 +700,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
// 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.
- State.Stack.back().LastSpace = State.Column;
+ if (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None)
+ State.Stack.back().LastSpace = State.Column;
} else if (Previous.is(TT_InheritanceColon)) {
State.Stack.back().Indent = State.Column;
State.Stack.back().LastSpace = State.Column;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 2e780e163be..d73b1d82671 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3375,6 +3375,18 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
" = bbbbbbbbbbbbbbbbb\n"
" >> aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa);",
Style);
+
+ Style.ColumnLimit = 80;
+ Style.IndentWidth = 4;
+ Style.TabWidth = 4;
+ Style.UseTab = FormatStyle::UT_Always;
+ Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+ Style.AlignOperands = false;
+ EXPECT_EQ("return someVeryVeryLongConditionThatBarelyFitsOnALine\n"
+ "\t&& (someOtherLongishConditionPart1\n"
+ "\t\t|| someOtherEvenLongerNestedConditionPart2);",
+ format("return someVeryVeryLongConditionThatBarelyFitsOnALine && (someOtherLongishConditionPart1 || someOtherEvenLongerNestedConditionPart2);",
+ Style));
}
TEST_F(FormatTest, EnforcedOperatorWraps) {
OpenPOWER on IntegriCloud