diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-28 17:30:17 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-28 17:30:17 +0000 |
commit | 48c62f980f6cdaf6a58956653c0793d361deff08 (patch) | |
tree | 6ad7561a3d43ecbe5eb0c20611748f0f13056f81 /clang/lib/Format | |
parent | 6cff9deb1605e9cfe7e7af182828b3fdc1409922 (diff) | |
download | bcm5719-llvm-48c62f980f6cdaf6a58956653c0793d361deff08.tar.gz bcm5719-llvm-48c62f980f6cdaf6a58956653c0793d361deff08.zip |
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) {}
llvm-svn: 173695
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/Format.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 21997817354..8eebda0740b 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/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; } |