clang-format: Properly set the BlockKind for more blocks.

Before:
  void f() { struct Dummy { };
    f();
  }

After:
  void f() {
    struct Dummy {};
    f();
  }

llvm-svn: 256175
This commit is contained in:
Daniel Jasper
2015-12-21 18:31:15 +00:00
parent 3e88a3200c
commit eb65e912aa
2 changed files with 10 additions and 2 deletions

View File

@@ -321,7 +321,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
SmallVector<FormatToken *, 8> LBraceStack;
assert(Tok->Tok.is(tok::l_brace));
do {
// Get next none-comment token.
// Get next non-comment token.
FormatToken *NextTok;
unsigned ReadTokens = 0;
do {
@@ -403,6 +403,7 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) &&
"'{' or macro block token expected");
const bool MacroBlock = FormatTok->is(TT_MacroBlockBegin);
FormatTok->BlockKind = BK_Block;
unsigned InitialLevel = Line->Level;
nextToken();
@@ -421,6 +422,7 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
: !FormatTok->is(tok::r_brace)) {
Line->Level = InitialLevel;
FormatTok->BlockKind = BK_Block;
return;
}