FormatTok = Tokens->setPosition(StoredPosition);
}
-void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel) {
+void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
+ bool MunchSemi) {
assert(FormatTok->Tok.is(tok::l_brace) && "'{' expected");
unsigned InitialLevel = Line->Level;
nextToken();
}
nextToken(); // Munch the closing brace.
+ if (MunchSemi && FormatTok->Tok.is(tok::semi))
+ nextToken();
Line->Level = InitialLevel;
}
Style.BreakBeforeBraces == FormatStyle::BS_Allman)
addUnwrappedLine();
- parseBlock(/*MustBeDeclaration=*/true);
+ parseBlock(/*MustBeDeclaration=*/true, /*Addlevel=*/true,
+ /*MunchSemi=*/false);
}
// We fall through to parsing a structural element afterwards, so
// class A {} n, m;
void reset();
void parseFile();
void parseLevel(bool HasOpeningBrace);
- void parseBlock(bool MustBeDeclaration, bool AddLevel = true);
+ void parseBlock(bool MustBeDeclaration, bool AddLevel = true,
+ bool MunchSemi = true);
void parseChildBlock();
void parsePPDirective();
void parsePPDefine();
getGoogleStyle()));
}
+TEST_F(FormatTest, MunchSemicolonAfterBlocks) {
+ verifyFormat("MY_CLASS(C) {\n"
+ " int i;\n"
+ " int j;\n"
+ "};");
+}
+
} // end namespace tooling
} // end namespace clang