]> granicus.if.org Git - clang/commitdiff
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367648 91177308-0d34-0410-b5e6-96231b3b80d8

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

index c69921619588a95a3536ac53ca2be59c0e50213b..589cf96b206951784fd2470eac21e2906ef6d95a 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 53a46283e1354b24d2fe9521dea1fc8cdfa3f6bb..528ad4b78c06255f09024587a5235263a1214ffa 100644 (file)
@@ -11086,6 +11086,9 @@ TEST_F(FormatTest, AllmanBraceBreaking) {
                "{\n"
                "  int x;\n"
                "};\n"
+               "union C\n"
+               "{\n"
+               "};\n"
                "} // namespace a",
                AllmanBraceStyle);