]> granicus.if.org Git - clang/commitdiff
Format unions like structs and classes.
authorDaniel Jasper <djasper@google.com>
Sun, 13 Jan 2013 14:39:04 +0000 (14:39 +0000)
committerDaniel Jasper <djasper@google.com>
Sun, 13 Jan 2013 14:39:04 +0000 (14:39 +0000)
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

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp

index 0c8ff890491d996cf9f765abc0998fa5057d4734..b3671b30409204b5c88e54f2a6c38531954ca06f 100644 (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;
index a46c9b685bcb0fe9c8ffd9bb21a873aa5ef1e6c9..f3da5061f263881c35ef2df9a019b35bdcbdd8aa 100644 (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) {