]> granicus.if.org Git - clang/commit
clang-format: Slightly change indentation rules in for loops.
authorDaniel Jasper <djasper@google.com>
Fri, 6 Mar 2015 10:57:12 +0000 (10:57 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 6 Mar 2015 10:57:12 +0000 (10:57 +0000)
commit36d0c630ba37b418a2b4244a1bbff413a5388e92
treed7bb09d46945473be20a03883f6e2f7a5e4098e6
parent6f99a6e74f772b1c6dc874e0e4f7e78275ae942d
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) {
  }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231461 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp