clang-format: Don't indent 'signals' as access specifier if it isn't one

Before:
  {
  signals.set(0);
  }

After:
  {
    signals.set(0);
  }

llvm-svn: 236630
This commit is contained in:
Daniel Jasper 2015-05-06 19:21:23 +00:00
parent 653c1099b4
commit 036181471c
2 changed files with 6 additions and 1 deletions

View File

@ -105,7 +105,9 @@ private:
Style.Language == FormatStyle::LK_JavaScript)
return 0;
if (RootToken.isAccessSpecifier(false) ||
RootToken.isObjCAccessSpecifier() || RootToken.is(Keywords.kw_signals))
RootToken.isObjCAccessSpecifier() ||
(RootToken.is(Keywords.kw_signals) && RootToken.Next &&
RootToken.Next->is(tok::colon)))
return Style.AccessModifierOffset;
return 0;
}

View File

@ -1939,6 +1939,9 @@ TEST_F(FormatTest, UnderstandsAccessSpecifiers) {
// Don't interpret 'signals' the wrong way.
verifyFormat("signals.set();");
verifyFormat("for (Signals signals : f()) {\n}");
verifyFormat("{\n"
" signals.set(); // This needs indentation.\n"
"}");
}
TEST_F(FormatTest, SeparatesLogicalBlocks) {