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/FormatTestJava.cpp15
2 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 24680ae76ca..40b50dde851 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -740,7 +740,8 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
// a builder type call after 'return' or, if the alignment after opening
// brackets is disabled.
if (!Current.isTrailingComment() &&
- (!Previous || Previous->isNot(tok::kw_return) || *I > 0) &&
+ (!Previous || Previous->isNot(tok::kw_return) ||
+ (Style.Language != FormatStyle::LK_Java && *I > 0)) &&
(Style.AlignAfterOpenBracket || *I != prec::Comma ||
Current.NestingLevel == 0))
NewParenState.Indent =
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 94070f46a06..cb96756e3d3 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -302,5 +302,20 @@ TEST_F(FormatTestJava, CppKeywords) {
verifyFormat("public void delete(Object o);");
}
+TEST_F(FormatTestJava, NeverAlignAfterReturn) {
+ verifyFormat("return aaaaaaaaaaaaaaaaaaa\n"
+ " && bbbbbbbbbbbbbbbbbbb\n"
+ " && ccccccccccccccccccc;",
+ getStyleWithColumns(40));
+ verifyFormat("return (result == null)\n"
+ " ? aaaaaaaaaaaaaaaaa\n"
+ " : bbbbbbbbbbbbbbbbb;",
+ getStyleWithColumns(40));
+ verifyFormat("return aaaaaaaaaaaaaaaaaaa()\n"
+ " .bbbbbbbbbbbbbbbbbbb()\n"
+ " .ccccccccccccccccccc();",
+ getStyleWithColumns(40));
+}
+
} // end namespace tooling
} // end namespace clang
OpenPOWER on IntegriCloud