clang-format: Fix fake parentheses placement with comments.

Before:
  return (a > b
          // comment1
      // comment2
      || c);

After:
  return (a > b
      // comment1
      // comment2
      || c);

llvm-svn: 223234
This commit is contained in:
Daniel Jasper 2014-12-03 14:02:59 +00:00
parent 7395cae005
commit c095663ec1
2 changed files with 8 additions and 1 deletions

View File

@ -1217,7 +1217,7 @@ private:
Start->StartsBinaryExpression = true;
if (Current) {
FormatToken *Previous = Current->Previous;
if (Previous->is(tok::comment) && Previous->Previous)
while (Previous->is(tok::comment) && Previous->Previous)
Previous = Previous->Previous;
++Previous->FakeRParens;
if (Precedence > prec::Unknown)

View File

@ -3337,6 +3337,13 @@ TEST_F(FormatTest, NoOperandAlignment) {
" + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"
" * cccccccccccccccccccccccccccccccccccc;",
Style);
Style.AlignAfterOpenBracket = false;
verifyFormat("return (a > b\n"
" // comment1\n"
" // comment2\n"
" || c);",
Style);
}
TEST_F(FormatTest, BreakingBeforeNonAssigmentOperators) {