summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-26 13:18:08 +0000
committerDaniel Jasper <djasper@google.com>2013-02-26 13:18:08 +0000
commit16b3562f00e8e55e34f6f4244b2ffddacce717df (patch)
tree96514d4d361943ad1d63e34bcc69270db257b023 /clang
parentfb5e241183e67c94159448e7a8113bef2c381ffe (diff)
downloadbcm5719-llvm-16b3562f00e8e55e34f6f4244b2ffddacce717df.tar.gz
bcm5719-llvm-16b3562f00e8e55e34f6f4244b2ffddacce717df.zip
In range-based for-loops, prefer splitting after ":".
Before: for (const aaaaaaaaaaaaaaaaaaaaa & aaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} After: for (const aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} llvm-svn: 176087
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp10
2 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 08290b905a4..83e1facb219 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -886,7 +886,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
if (Left.Type == TT_RangeBasedForLoopColon ||
Left.Type == TT_InheritanceColon)
- return 5;
+ return 2;
if (Right.is(tok::arrow) || Right.is(tok::period)) {
if (Line.Type == LT_BuilderTypeCall)
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 53f3773d5c1..9e777c66e99 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -318,6 +318,8 @@ TEST_F(FormatTest, RangeBasedForLoops) {
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}");
verifyFormat("for (auto aaaaaaaaaaaaaaaaaaaaa :\n"
" aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa, aaaaaaaaaaaaa)) {\n}");
+ verifyFormat("for (const aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaa :\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}");
}
TEST_F(FormatTest, FormatsWhileLoop) {
@@ -601,10 +603,10 @@ TEST_F(FormatTest, CommentsInStaticInitializers) {
" b\n"
"}"));
EXPECT_EQ("S s = { a, b };", format("S s = {\n"
- " a,\n"
- "\n"
- " b\n"
- "};"));
+ " a,\n"
+ "\n"
+ " b\n"
+ "};"));
}
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud