Fix a bug where we would move a following line into a comment.

Before: Constructor() : a(a), // comment a(a) {}
After:  Constructor() : a(a), // comment
                        a(a) {}

Needed this as a quick fix. Will add more tests for this in a future
commit.

llvm-svn: 172624
This commit is contained in:
Daniel Jasper 2013-01-16 17:00:50 +00:00
parent 99b0a6a03a
commit 69987d5415
2 changed files with 6 additions and 1 deletions

View File

@ -492,7 +492,7 @@ private:
if (Previous.is(tok::l_paren) || Previous.is(tok::l_brace) ||
State.NextToken->Parent->Type == TT_TemplateOpener)
State.Stack[ParenLevel].Indent = State.Column + Spaces;
if (Previous.is(tok::comma))
if (Previous.is(tok::comma) && Current.Type != TT_LineComment)
State.Stack[ParenLevel].HasMultiParameterLine = true;

View File

@ -746,6 +746,11 @@ TEST_F(FormatTest, ConstructorInitializers) {
" : aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {}");
verifyGoogleFormat(
"SomeClass::Constructor()\n"
" : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), // Some comment\n"
" aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {}");
verifyFormat(
"SomeClass::Constructor()\n"