Fix an error in formatting of for-loops.
Two minor changes:
* Slight penalty for breaking at "," as opposed to ";".
* Don't apply bin-packing rules to for-loops.
Before:
for (int aaaaaa = aaaaaaaaaa; aaaaaa < bbbbbbbb; ++aaaaaa,
++ccccccccccccccc) {}
After:
for (int aaaaaa = aaaaaaaaaa; aaaaaa < bbbbbbbb;
++aaaaaa, ++ccccccccccccccc) {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174308 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 1eb7021..0676df6 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -714,8 +714,10 @@
(Left.isNot(tok::comma) && Left.isNot(tok::semi)))
return 20;
- if (Left.is(tok::semi) || Left.is(tok::comma))
+ if (Left.is(tok::semi))
return 0;
+ if (Left.is(tok::comma))
+ return 1;
// In Objective-C method expressions, prefer breaking before "param:" over
// breaking after it.