summaryrefslogtreecommitdiffstats
path: root/clang/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-08-28 10:03:58 +0000
committerDaniel Jasper <djasper@google.com>2013-08-28 10:03:58 +0000
commit2739af3b9cce00b7bda893162ccb2e7951f7c2e7 (patch)
tree421b10b9954217cb11e8004d616a1658fa7dd74b /clang/unittests
parent2d999ebb84280a50c2547293cfa44d323d66de1f (diff)
downloadbcm5719-llvm-2739af3b9cce00b7bda893162ccb2e7951f7c2e7.tar.gz
bcm5719-llvm-2739af3b9cce00b7bda893162ccb2e7951f7c2e7.zip
clang-format: Improve token breaking behavior.
Two changes: * Don't add an extra penalty on breaking the same token multiple times. Generally, we should prefer not to break, but once we break, the normal line breaking penalties apply. * Slightly increase the penalty for breaking comments. In general, the author has put some thought into how to break the comment and we should not overwrite this unnecessarily. With a 40-column column limit, formatting aaaaaa("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"); Leads to: Before: aaaaaa( "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaa"); After: aaaaaa("aaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaa"); llvm-svn: 189466
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/Format/FormatTest.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 067a259b2ce..122b367a223 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -970,8 +970,8 @@ TEST_F(FormatTest, DontSplitLineCommentsWithEscapedNewlines) {
}
TEST_F(FormatTest, PriorityOfCommentBreaking) {
- EXPECT_EQ("if (xxx == yyy && // aaaaaaaaaaaa\n"
- " // bbbbbbbbb\n"
+ EXPECT_EQ("if (xxx ==\n"
+ " yyy && // aaaaaaaaaaaa bbbbbbbbb\n"
" zzz)\n"
" q();",
format("if (xxx == yyy && // aaaaaaaaaaaa bbbbbbbbb\n"
@@ -5392,10 +5392,10 @@ TEST_F(FormatTest, BreakStringLiteralsBeforeUnbreakableTokenSequence) {
" \"f\");",
format("someFunction1234567890(\"aaabbbcccdddeeefff\");",
getLLVMStyleWithColumns(24)));
- EXPECT_EQ("someFunction(\n"
- " \"aaabbbcc \"\n"
- " \"dddeeefff\");",
- format("someFunction(\"aaabbbcc dddeeefff\");",
+ EXPECT_EQ("someFunction(\"aaabbbcc \"\n"
+ " \"ddde \"\n"
+ " \"efff\");",
+ format("someFunction(\"aaabbbcc ddde efff\");",
getLLVMStyleWithColumns(25)));
EXPECT_EQ("someFunction(\"aaabbbccc \"\n"
" \"ddeeefff\");",
@@ -5413,6 +5413,12 @@ TEST_F(FormatTest, BreakStringLiteralsBeforeUnbreakableTokenSequence) {
" int i;",
format("#define A string s = \"1234567890\"; int i;",
getLLVMStyleWithColumns(20)));
+ // FIXME: Put additional penalties on breaking at non-whitespace locations.
+ EXPECT_EQ("someFunction(\"aaabbbcc \"\n"
+ " \"dddeeeff\"\n"
+ " \"f\");",
+ format("someFunction(\"aaabbbcc dddeeefff\");",
+ getLLVMStyleWithColumns(25)));
}
TEST_F(FormatTest, DoNotBreakStringLiteralsInEscapeSequence) {
OpenPOWER on IntegriCloud