summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-16 17:00:50 +0000
committerDaniel Jasper <djasper@google.com>2013-01-16 17:00:50 +0000
commit69987d5415f2260540be1cafa460362ad74ae849 (patch)
treed9cd541a6924b550e762c77d1f06538934b50f07
parent99b0a6a03a3ad7285478242b6522683112888a63 (diff)
downloadbcm5719-llvm-69987d5415f2260540be1cafa460362ad74ae849.tar.gz
bcm5719-llvm-69987d5415f2260540be1cafa460362ad74ae849.zip
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
-rw-r--r--clang/lib/Format/Format.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp5
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 22166aa27ab..069d2dae712 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 3c92d82f8fb..df050a4e298 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"
OpenPOWER on IntegriCloud