Format unions like structs and classes.

Note that I don't know whether we should put {} on a single line in this
case, but it is probably a theoretical issue as in practice such
structs, classes or unions won't be empty.

Before: union A {}
        a;
After:  union A {} a;
llvm-svn: 172355
This commit is contained in:
Daniel Jasper 2013-01-13 14:39:04 +00:00
parent 953fb087e5
commit 22cf462234
2 changed files with 3 additions and 1 deletions

View File

@ -317,7 +317,8 @@ void UnwrappedLineParser::parseStructuralElement() {
case tok::kw_enum:
parseEnum();
return;
case tok::kw_struct: // fallthrough
case tok::kw_struct: // fallthrough
case tok::kw_union: // fallthrough
case tok::kw_class:
parseStructClassOrBracedList();
return;

View File

@ -343,6 +343,7 @@ TEST_F(FormatTest, FormatsDerivedClass) {
TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
verifyFormat("class A {} a, b;");
verifyFormat("struct A {} a, b;");
verifyFormat("union A {} a;");
}
TEST_F(FormatTest, FormatsEnum) {