diff options
| author | Daniel Jasper <djasper@google.com> | 2015-06-09 13:16:54 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-06-09 13:16:54 +0000 |
| commit | dee894f6bb0b6a16b00d834b40946e8592c2b54e (patch) | |
| tree | c461158df4c792231075baf62b1ab1654c2a5f0d /clang | |
| parent | 6b62b659cbcd51e6dcedd5cf0e8501e74ffd9852 (diff) | |
| download | bcm5719-llvm-dee894f6bb0b6a16b00d834b40946e8592c2b54e.tar.gz bcm5719-llvm-dee894f6bb0b6a16b00d834b40946e8592c2b54e.zip | |
clang-format: Support //!-comments, increase test coverage.
llvm-svn: 239404
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/BreakableToken.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 66e935abdf5..e3e162d070f 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -183,7 +183,7 @@ void BreakableStringLiteral::insertBreak(unsigned LineIndex, } static StringRef getLineCommentIndentPrefix(StringRef Comment) { - static const char *const KnownPrefixes[] = { "///", "//" }; + static const char *const KnownPrefixes[] = { "///", "//", "//!" }; StringRef LongestPrefix; for (StringRef KnownPrefix : KnownPrefixes) { if (Comment.startswith(KnownPrefix)) { @@ -210,6 +210,8 @@ BreakableLineComment::BreakableLineComment( Prefix = "// "; else if (Prefix == "///") Prefix = "/// "; + else if (Prefix == "//!") + Prefix = "//! "; } } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 0760530672b..c4aa712ba1d 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1337,6 +1337,16 @@ TEST_F(FormatTest, SplitsLongCxxComments) { "// one line", format("// A comment that doesn't fit on one line", getLLVMStyleWithColumns(20))); + EXPECT_EQ("/// A comment that\n" + "/// doesn't fit on\n" + "/// one line", + format("/// A comment that doesn't fit on one line", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("//! A comment that\n" + "//! doesn't fit on\n" + "//! one line", + format("//! A comment that doesn't fit on one line", + getLLVMStyleWithColumns(20))); EXPECT_EQ("// a b c d\n" "// e f g\n" "// h i j k", @@ -1357,6 +1367,12 @@ TEST_F(FormatTest, SplitsLongCxxComments) { EXPECT_EQ("// Add leading\n" "// whitespace", format("//Add leading whitespace", getLLVMStyleWithColumns(20))); + EXPECT_EQ("/// Add leading\n" + "/// whitespace", + format("///Add leading whitespace", getLLVMStyleWithColumns(20))); + EXPECT_EQ("//! Add leading\n" + "//! whitespace", + format("//!Add leading whitespace", getLLVMStyleWithColumns(20))); EXPECT_EQ("// whitespace", format("//whitespace", getLLVMStyle())); EXPECT_EQ("// Even if it makes the line exceed the column\n" "// limit", |

