summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-03-06 10:57:12 +0000
committerDaniel Jasper <djasper@google.com>2015-03-06 10:57:12 +0000
commit98f8ae34da229b16a59953731651c0b37933b74c (patch)
treedcef8ca2d2e2c3500ea256510c24d83505bf7d83 /clang/lib/Format/ContinuationIndenter.cpp
parent78521ef545bbf6c6aba29368fb011e1280f3541d (diff)
downloadbcm5719-llvm-98f8ae34da229b16a59953731651c0b37933b74c.tar.gz
bcm5719-llvm-98f8ae34da229b16a59953731651c0b37933b74c.zip
clang-format: Slightly change indentation rules in for loops.
There was already a TODO to double-check whether the extra indenation makes sense. A slightly different case reveals that it is actively harmful: for (int i = 0; i < aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbb < ccccccccccccccc; ++i) { } Here (and it is probably not a totally infrequent case, it just works out that "i < " is four spaces and so the four space extra indentation makes the operator precedence confusing. So, this will now instead be formatted as: for (int i = 0; i < aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbb < ccccccccccccccc; ++i) { } llvm-svn: 231461
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 7c2d916ac5c..17a007f8b2a 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -722,7 +722,8 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
// 'return', assignments or opening <({[. The indentation for these cases
// is special cased.
bool SkipFirstExtraIndent =
- (Previous && (Previous->opensScope() || Previous->is(tok::kw_return) ||
+ (Previous && (Previous->opensScope() ||
+ Previous->isOneOf(tok::semi, tok::kw_return) ||
(Previous->getPrecedence() == prec::Assignment &&
Style.AlignOperands) ||
Previous->is(TT_ObjCMethodExpr)));
OpenPOWER on IntegriCloud