From: Daniel Jasper Date: Sun, 13 Jan 2013 14:39:04 +0000 (+0000) Subject: Format unions like structs and classes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1774603d8b34f86bd254d85a125592fcb323a488;p=clang 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; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172355 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 0c8ff89049..b3671b3040 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index a46c9b685b..f3da5061f2 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) {