aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-28 17:30:17 +0000
committerDaniel Jasper <djasper@google.com>2013-01-28 17:30:17 +0000
commit7522318ce2b2280dc679b62a4193c8f179632c16 (patch)
treee85779dc66278a8f5ba716df56b21d1b387e78d0 /lib/Format/Format.cpp
parent531b47c22e58146b2720677518bdd459eb0e907d (diff)
Fix a bug that would lead to bad line break decisions in for loops.
Before: for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa = aaaaaaaaaaaaaaa .aaaaaaaaaaaaaaaa; aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {} After: for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa = aaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaa; aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173695 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r--lib/Format/Format.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 2199781735..8eebda0740 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -723,6 +723,12 @@ private:
if (Left.Type == TT_RangeBasedForLoopColon)
return 5;
+ if (Right.is(tok::arrow) || Right.is(tok::period)) {
+ if (Left.is(tok::r_paren) && Line.Type == LT_BuilderTypeCall)
+ return 5; // Should be smaller than breaking at a nested comma.
+ return 150;
+ }
+
// In for-loops, prefer breaking at ',' and ';'.
if (RootToken.is(tok::kw_for) &&
(Left.isNot(tok::comma) && Left.isNot(tok::semi)))
@@ -753,12 +759,6 @@ private:
if (Level != prec::Unknown)
return Level;
- if (Right.is(tok::arrow) || Right.is(tok::period)) {
- if (Left.is(tok::r_paren) && Line.Type == LT_BuilderTypeCall)
- return 5; // Should be smaller than breaking at a nested comma.
- return 150;
- }
-
return 3;
}