diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-07-16 23:47:22 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-07-16 23:47:22 +0000 |
commit | 940423424140fc791f3dc242ea35eab11de925ad (patch) | |
tree | 081ad459a9c777b1f00d4e48bc1da310c47baaeb | |
parent | 8bfde8917ed77b89fe916854b67352884ffb7b16 (diff) | |
download | bcm5719-llvm-940423424140fc791f3dc242ea35eab11de925ad.tar.gz bcm5719-llvm-940423424140fc791f3dc242ea35eab11de925ad.zip |
Avoid breaking non-trailing block comments.
Motivating example:
// column limit ------------------->
void ffffffffffff(int aaaaaa /* test */);
Formatting before the patch:
void ffffffffffff(int aaaaaa /* test
*/);
Formatting after the patch:
void
ffffffffffff(int aaaaaa /* test */);
llvm-svn: 186471
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 11ab58c18cd..125283a0c6d 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -917,7 +917,7 @@ private: Token.reset(new BreakableStringLiteral(Current, StartColumn, Line.InPPDirective, Encoding)); - } else if (Current.Type == TT_BlockComment) { + } else if (Current.Type == TT_BlockComment && Current.isTrailingComment()) { Token.reset(new BreakableBlockComment( Style, Current, StartColumn, OriginalStartColumn, !Current.Previous, Line.InPPDirective, Encoding)); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 433d0ec1d71..3b8f91130ff 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -866,6 +866,13 @@ TEST_F(FormatTest, CorrectlyHandlesLengthOfBlockComments) { getLLVMStyleWithColumns(40))); } +TEST_F(FormatTest, DontBreakNonTrailingBlockComments) { + EXPECT_EQ("void\n" + "ffffffffff(int aaaaa /* test */);", + format("void ffffffffff(int aaaaa /* test */);", + getLLVMStyleWithColumns(35))); +} + TEST_F(FormatTest, SplitsLongCxxComments) { EXPECT_EQ("// A comment that\n" "// doesn't fit on\n" |