From 69987d5415f2260540be1cafa460362ad74ae849 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 16 Jan 2013 17:00:50 +0000 Subject: [PATCH] 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 --- clang/lib/Format/Format.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 22166aa..069d2da 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -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; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 3c92d82..df050a4 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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" -- 2.7.4