r221125 - clang-format: [Java] Allow trailing semicolons after enums.
Daniel Jasper
djasper at google.com
Sun Nov 2 19:00:42 PST 2014
Author: djasper
Date: Sun Nov 2 21:00:42 2014
New Revision: 221125
URL: http://llvm.org/viewvc/llvm-project?rev=221125&view=rev
Log:
clang-format: [Java] Allow trailing semicolons after enums.
Before:
enum SomeThing { ABC, CDE }
;
After:
enum SomeThing { ABC, CDE };
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=221125&r1=221124&r2=221125&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Sun Nov 2 21:00:42 2014
@@ -1354,11 +1354,10 @@ void UnwrappedLineParser::parseEnum() {
if (FormatTok->Tok.is(tok::l_brace)) {
FormatTok->BlockKind = BK_Block;
bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
- if (HasError) {
- if (FormatTok->is(tok::semi))
- nextToken();
+ if (FormatTok->is(tok::semi))
+ nextToken();
+ if (HasError)
addUnwrappedLine();
- }
}
// We fall through to parsing a structural element afterwards, so that in
// enum A {} n, m;
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=221125&r1=221124&r2=221125&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Sun Nov 2 21:00:42 2014
@@ -86,6 +86,7 @@ TEST_F(FormatTestJava, ClassDeclarations
TEST_F(FormatTestJava, EnumDeclarations) {
verifyFormat("enum SomeThing { ABC, CDE }");
+ verifyFormat("enum SomeThing { ABC, CDE };");
verifyFormat("enum SomeThing {\n"
" ABC,\n"
" CDE,\n"
More information about the cfe-commits
mailing list