diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-07-08 14:12:07 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-07-08 14:12:07 +0000 |
commit | 614d96a1f689ee126e974f8c8d15194a9d881075 (patch) | |
tree | 10f3d3fa71520ea51f421e5c1e022b96c2bbb6d2 /clang/unittests/Format/FormatTest.cpp | |
parent | ddd7b6a1c8dc21e700a20d05a12210e6c063a510 (diff) | |
download | bcm5719-llvm-614d96a1f689ee126e974f8c8d15194a9d881075.tar.gz bcm5719-llvm-614d96a1f689ee126e974f8c8d15194a9d881075.zip |
Fix for corner cases in code handling leading "* " decorations in block comments
Summary:
Fixes problems that lead to incorrect formatting of these and similar snippets:
/*
**
*/
/*
**/
/*
* */
/*
*test
*/
Clang-format used to think that all the cases above use "* " decoration, and
failed to calculate insertion position properly. It also used to remove leading
"* " in the last line.
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1113
llvm-svn: 185818
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 96ea9de9c67..cff178eeb97 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3967,7 +3967,7 @@ TEST_F(FormatTest, BlockComments) { EXPECT_EQ("/*\n" "*\n" " * aaaaaa\n" - "* aaaaaa\n" + "*aaaaaa\n" "*/", format("/*\n" "*\n" @@ -3977,7 +3977,7 @@ TEST_F(FormatTest, BlockComments) { EXPECT_EQ("/*\n" "**\n" "* aaaaaa\n" - "* aaaaaa\n" + "*aaaaaa\n" "*/", format("/*\n" "**\n" @@ -4017,6 +4017,33 @@ TEST_F(FormatTest, BlockComments) { "int cccccccccccccccccccccccccccccc; /* comment */\n")); verifyFormat("void f(int * /* unused */) {}"); + + EXPECT_EQ("/*\n" + " **\n" + " */", + format("/*\n" + " **\n" + " */")); + EXPECT_EQ("/*\n" + " *q\n" + " */", + format("/*\n" + " *q\n" + " */")); + EXPECT_EQ("/*\n" + " * q\n" + " */", + format("/*\n" + " * q\n" + " */")); + EXPECT_EQ("/*\n" + " **/", + format("/*\n" + " **/")); + EXPECT_EQ("/*\n" + " ***/", + format("/*\n" + " ***/")); } TEST_F(FormatTest, BlockCommentsInMacros) { |