r176027 - Re-add hack that caused regression.
Daniel Jasper
djasper at google.com
Mon Feb 25 07:59:54 PST 2013
Author: djasper
Date: Mon Feb 25 09:59:54 2013
New Revision: 176027
URL: http://llvm.org/viewvc/llvm-project?rev=176027&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=176027&r1=176026&r2=176027&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Feb 25 09:59:54 2013
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=176027&r1=176026&r2=176027&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb 25 09:59:54 2013
@@ -1132,6 +1132,10 @@ TEST_F(FormatTest, ConstructorInitialize
" : 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(
More information about the cfe-commits
mailing list