aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/Format.cpp3
-rw-r--r--lib/Format/TokenAnnotator.cpp3
-rw-r--r--unittests/Format/FormatTest.cpp8
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index e950fe6030..d8ef5cf785 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -549,6 +549,9 @@ private:
// If this function has multiple parameters, indent nested calls from
// the start of the first parameter.
State.Stack.back().LastSpace = State.Column;
+ else if ((Current.is(tok::period) || Current.is(tok::arrow)) &&
+ Line.Type == LT_BuilderTypeCall && State.ParenLevel == 0)
+ State.Stack.back().LastSpace = State.Column;
}
// If we break after an {, we should also break before the corresponding }.
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 92c3f1d41c..bb2e04b66e 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -471,8 +471,7 @@ public:
if (!consumeToken())
return LT_Invalid;
if (getPrecedence(*TheToken) > prec::Assignment &&
- TheToken->Type != TT_TemplateOpener &&
- TheToken->Type != TT_TemplateCloser)
+ TheToken->Type == TT_BinaryOperator)
CanBeBuilderTypeStmt = false;
}
if (KeywordVirtualFound)
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index d69b95e766..fb388ab7f9 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1259,6 +1259,14 @@ TEST_F(FormatTest, FormatsBuilderPattern) {
"aaaaaaa->aaaaaaa\n"
" ->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
" ->aaaaaaaa(aaaaaaaaaaaaaaa);");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break\n"
+ " aaaaaaaaaaaaaa);");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa()\n"
+ " ->aaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
+ " ->aaaaaaaaaaaaaaaaa();");
}
TEST_F(FormatTest, DoesNotBreakTrailingAnnotation) {