From: Daniel Jasper Date: Tue, 9 Jun 2015 13:16:54 +0000 (+0000) Subject: clang-format: Support //!-comments, increase test coverage. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3db9851d2c0ee387b133a483a50c1310af19a50e;p=clang clang-format: Support //!-comments, increase test coverage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239404 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp index 66e935abdf..e3e162d070 100644 --- a/lib/Format/BreakableToken.cpp +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 0760530672..c4aa712ba1 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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",