summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-01-12 10:23:24 +0000
committerDaniel Jasper <djasper@google.com>2015-01-12 10:23:24 +0000
commitd6a1cab1bcf509645b5119d92e95bbd7ab5131a3 (patch)
treed7e28dd1d1cc1dafcef09263ccbd48b7777c0226
parent19acc3d351628017c4fcfb00112302d55115a11e (diff)
downloadbcm5719-llvm-d6a1cab1bcf509645b5119d92e95bbd7ab5131a3.tar.gz
bcm5719-llvm-d6a1cab1bcf509645b5119d92e95bbd7ab5131a3.zip
clang-format: Improve format of lambdas in ctor initializers.
Before: Constructor() : Constructor([] { // comment int i; }) {} After: Constructor() : Constructor([] { // comment int i; }) {} llvm-svn: 225625
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp1
-rw-r--r--clang/unittests/Format/FormatTest.cpp4
2 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index f05471e712d..4cc92b02a9e 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -632,6 +632,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
// ^ line up here.
State.Stack.back().Indent =
State.Column + (Style.BreakConstructorInitializersBeforeComma ? 0 : 2);
+ State.Stack.back().NestedBlockIndent = State.Stack.back().Indent;
if (Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
State.Stack.back().AvoidBinPacking = true;
State.Stack.back().BreakBeforeParameter = false;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index a49a35c1def..3bb55402e71 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9380,6 +9380,10 @@ TEST_F(FormatTest, FormatsLambdas) {
verifyFormat("string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() {\n"
" SomeOtherFunctioooooooooooooooooooooooooon();\n"
"});");
+ verifyFormat("Constructor()\n"
+ " : Field([] { // comment\n"
+ " int i;\n"
+ " }) {}");
// Lambdas with return types.
verifyFormat("int c = []() -> int { return 2; }();\n");
OpenPOWER on IntegriCloud