summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp61
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp7
3 files changed, 37 insertions, 34 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 3e4bf3e88a3..a2a68bd6d48 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -849,7 +849,8 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
bool NoLineBreak = State.Stack.back().NoLineBreak ||
(Current.is(TT_TemplateOpener) &&
State.Stack.back().ContainsUnwrappedBuilder);
- unsigned NestedBlockIndent = State.Stack.back().NestedBlockIndent;
+ unsigned NestedBlockIndent = std::max(State.Stack.back().StartOfFunctionCall,
+ State.Stack.back().NestedBlockIndent);
State.Stack.push_back(ParenState(NewIndent, NewIndentLevel,
State.Stack.back().LastSpace,
AvoidBinPacking, NoLineBreak));
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index bf98eceacd8..183fa4418be 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3048,35 +3048,38 @@ TEST_F(FormatTest, FormatsJoinedLinesOnSubsequentRuns) {
}
TEST_F(FormatTest, LayoutBlockInsideParens) {
- EXPECT_EQ("functionCall({ int i; });", format(" functionCall ( {int i;} );"));
- EXPECT_EQ("functionCall({\n"
- " int i;\n"
- " int j;\n"
- "});",
- format(" functionCall ( {int i;int j;} );"));
- EXPECT_EQ("functionCall({\n"
- " int i;\n"
- " int j;\n"
- "}, aaaa, bbbb, cccc);",
- format(" functionCall ( {int i;int j;}, aaaa, bbbb, cccc);"));
- EXPECT_EQ("functionCall(\n"
- " {\n"
- " int i;\n"
- " int j;\n"
- " },\n"
- " aaaa, bbbb, // comment\n"
- " cccc);",
- format(" functionCall ( {int i;int j;}, aaaa, bbbb, // comment\n"
- "cccc);"));
- EXPECT_EQ("functionCall(aaaa, bbbb, { int i; });",
- format(" functionCall (aaaa, bbbb, {int i;});"));
- EXPECT_EQ("functionCall(aaaa, bbbb, {\n"
- " int i;\n"
- " int j;\n"
- "});",
- format(" functionCall (aaaa, bbbb, {int i;int j;});"));
- EXPECT_EQ("functionCall(aaaa, bbbb, { int i; });",
- format(" functionCall (aaaa, bbbb, {int i;});"));
+ verifyFormat("functionCall({ int i; });");
+ verifyFormat("functionCall({\n"
+ " int i;\n"
+ " int j;\n"
+ "});");
+ verifyFormat("functionCall({\n"
+ " int i;\n"
+ " int j;\n"
+ "}, aaaa, bbbb, cccc);");
+ verifyFormat("functionA(functionB({\n"
+ " int i;\n"
+ " int j;\n"
+ " }),\n"
+ " aaaa, bbbb, cccc);");
+ verifyFormat("functionCall(\n"
+ " {\n"
+ " int i;\n"
+ " int j;\n"
+ " },\n"
+ " aaaa, bbbb, // comment\n"
+ " cccc);");
+ verifyFormat("functionA(functionB({\n"
+ " int i;\n"
+ " int j;\n"
+ " }),\n"
+ " aaaa, bbbb, // comment\n"
+ " cccc);");
+ verifyFormat("functionCall(aaaa, bbbb, { int i; });");
+ verifyFormat("functionCall(aaaa, bbbb, {\n"
+ " int i;\n"
+ " int j;\n"
+ "});");
verifyFormat(
"Aaa(\n" // FIXME: There shouldn't be a linebreak here.
" {\n"
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 35727eb686b..76c2730960e 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -408,10 +408,9 @@ TEST_F(FormatTestJS, MultipleFunctionLiterals) {
" body();\n"
" });");
- // FIXME: This is bad, but it used to be formatted correctly by accident.
- verifyFormat("getSomeLongPromise().then(function(value) {\n"
- " body();\n"
- "}).thenCatch(function(error) { body(); });");
+ verifyFormat("getSomeLongPromise()\n"
+ " .then(function(value) { body(); })\n"
+ " .thenCatch(function(error) { body(); });");
}
TEST_F(FormatTestJS, ReturnStatements) {
OpenPOWER on IntegriCloud