소스 검색

[clang-format] Fix a bug that doesn't break braces before unions for Allman
Differential Revision: https://reviews.llvm.org/D65631

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

Owen Pan 6 년 전
부모
커밋
d0e06d7ab5
2개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      lib/Format/Format.cpp
  2. 3 0
      unittests/Format/FormatTest.cpp

+ 1 - 0
lib/Format/Format.cpp

@@ -640,6 +640,7 @@ static FormatStyle expandPresets(const FormatStyle &Style) {
     Expanded.BraceWrapping.AfterNamespace = true;
     Expanded.BraceWrapping.AfterNamespace = true;
     Expanded.BraceWrapping.AfterObjCDeclaration = true;
     Expanded.BraceWrapping.AfterObjCDeclaration = true;
     Expanded.BraceWrapping.AfterStruct = true;
     Expanded.BraceWrapping.AfterStruct = true;
+    Expanded.BraceWrapping.AfterUnion = true;
     Expanded.BraceWrapping.AfterExternBlock = true;
     Expanded.BraceWrapping.AfterExternBlock = true;
     Expanded.BraceWrapping.BeforeCatch = true;
     Expanded.BraceWrapping.BeforeCatch = true;
     Expanded.BraceWrapping.BeforeElse = true;
     Expanded.BraceWrapping.BeforeElse = true;

+ 3 - 0
unittests/Format/FormatTest.cpp

@@ -11086,6 +11086,9 @@ TEST_F(FormatTest, AllmanBraceBreaking) {
                "{\n"
                "{\n"
                "  int x;\n"
                "  int x;\n"
                "};\n"
                "};\n"
+               "union C\n"
+               "{\n"
+               "};\n"
                "} // namespace a",
                "} // namespace a",
                AllmanBraceStyle);
                AllmanBraceStyle);