aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-25 15:59:54 +0000
committerDaniel Jasper <djasper@google.com>2013-02-25 15:59:54 +0000
commit9c3e71acb53a67f305a54f3d6d6decb143acaae4 (patch)
treefd90880fc525ebfb8ea528c6b5645cd2101bbf6b
parent3abf77872ca6c520903f9174cf6cd89a50df2714 (diff)
Re-add hack that caused regression.
This fixes llvm.org/PR15350. Before: Constructor(int Parameter = 0) : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa), aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {} After: Constructor(int Parameter = 0) : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa), aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {} I think the correct solution is to put the VariablePos into ParenState, not LineState. Added FIXME. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176027 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Format/Format.cpp4
-rw-r--r--unittests/Format/FormatTest.cpp4
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 60fe957a12..00ec79f5e4 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -552,7 +552,9 @@ private:
State.Stack.back().BreakBeforeParameter = true;
}
} else {
- if (Current.is(tok::equal))
+ // FIXME: Put VariablePos into ParenState and remove second part of if().
+ if (Current.is(tok::equal) &&
+ (RootToken.is(tok::kw_for) || State.ParenLevel == 0))
State.VariablePos = State.Column - Previous.FormatTok.TokenLength;
unsigned Spaces = State.NextToken->SpacesRequiredBefore;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 94ac4cf59f..17dae0ffe6 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1132,6 +1132,10 @@ TEST_F(FormatTest, ConstructorInitializers) {
" : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}");
+ verifyFormat("Constructor(int Parameter = 0)\n"
+ " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),\n"
+ " aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}");
+
// Here a line could be saved by splitting the second initializer onto two
// lines, but that is not desireable.
verifyFormat(