[clang-format] Fix a bug that doesn't break braces before unions for Allman
authorOwen Pan <owenpiano@gmail.com>
Fri, 2 Aug 2019 04:30:42 +0000 (04:30 +0000)
committerOwen Pan <owenpiano@gmail.com>
Fri, 2 Aug 2019 04:30:42 +0000 (04:30 +0000)
Differential Revision: https://reviews.llvm.org/D65631

llvm-svn: 367648

clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

index c699216..589cf96 100644 (file)
@@ -640,6 +640,7 @@ static FormatStyle expandPresets(const FormatStyle &Style) {
     Expanded.BraceWrapping.AfterNamespace = true;
     Expanded.BraceWrapping.AfterObjCDeclaration = true;
     Expanded.BraceWrapping.AfterStruct = true;
+    Expanded.BraceWrapping.AfterUnion = true;
     Expanded.BraceWrapping.AfterExternBlock = true;
     Expanded.BraceWrapping.BeforeCatch = true;
     Expanded.BraceWrapping.BeforeElse = true;
index 53a4628..528ad4b 100644 (file)
@@ -11086,6 +11086,9 @@ TEST_F(FormatTest, AllmanBraceBreaking) {
                "{\n"
                "  int x;\n"
                "};\n"
+               "union C\n"
+               "{\n"
+               "};\n"
                "} // namespace a",
                AllmanBraceStyle);