summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-12-08 21:28:31 +0000
committerDaniel Jasper <djasper@google.com>2014-12-08 21:28:31 +0000
commita536df4b28b2ab1ab495d45d674e32f5eec23a28 (patch)
treed19137ad3b3e7ac6947ba680b437c2895a7e0fdc
parent025f860638d20ed3c9774934f301647643ac8dc8 (diff)
downloadbcm5719-llvm-a536df4b28b2ab1ab495d45d674e32f5eec23a28.tar.gz
bcm5719-llvm-a536df4b28b2ab1ab495d45d674e32f5eec23a28.zip
clang-format: Indent correctly in conditional expressions after return.
This only applies when not aligning after the return itself (which is commonly done for C++. Before: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) // This is indented relative to aaaaaaaaaa. : b; After: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) : b; llvm-svn: 223694
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp3
-rw-r--r--clang/unittests/Format/FormatTestJava.cpp5
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 8538f9a4601..5f55e0daa06 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -766,7 +766,8 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
// ParameterToInnerFunction));
if (*I > prec::Unknown)
NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column);
- NewParenState.StartOfFunctionCall = State.Column;
+ if (*I != prec::Conditional)
+ NewParenState.StartOfFunctionCall = State.Column;
// Always indent conditional expressions. Never indent expression where
// the 'operator' is ',', ';' or an assignment (i.e. *I <=
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 91b38ad7588..6f7e43f325c 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -373,6 +373,11 @@ TEST_F(FormatTestJava, NeverAlignAfterReturn) {
" .bbbbbbbbbbbbbbbbbbb()\n"
" .ccccccccccccccccccc();",
getStyleWithColumns(40));
+ verifyFormat("return aaaaaaaaaaaaaaaaaaa()\n"
+ " .bbbbbbbbbbbbbbbbbbb(\n"
+ " ccccccccccccccc)\n"
+ " .ccccccccccccccccccc();",
+ getStyleWithColumns(40));
}
TEST_F(FormatTestJava, FormatsInnerBlocks) {
OpenPOWER on IntegriCloud