]> granicus.if.org Git - clang/commitdiff
clang-format: Don't merge simple blocks in case statements.
authorDaniel Jasper <djasper@google.com>
Fri, 4 Apr 2014 06:46:23 +0000 (06:46 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 4 Apr 2014 06:46:23 +0000 (06:46 +0000)
Before:
  switch (a) {
  case 1: { return 'a'; }
  }

After:
  switch (a) {
  case 1: {
    return 'a';
  }
  }

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

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

index cb07cb56a555da5a3d035bc8a805c82a3ed2c718..44116a8f8e35fb58622de6d84db7721b48f4f002 100644 (file)
@@ -623,7 +623,7 @@ private:
     AnnotatedLine &Line = **I;
     if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::r_brace,
                             tok::kw_else, tok::kw_try, tok::kw_catch,
-                            tok::kw_for,
+                            tok::kw_for, tok::kw_case,
                             // This gets rid of all ObjC @ keywords and methods.
                             tok::at, tok::minus, tok::plus))
       return 0;
index 76062605f706028becd58fff5f5905aad2deaca4..90e6ff72037b37ea3d0aee890436d5446615d135 100644 (file)
@@ -511,6 +511,9 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
                "  f();\n"
                "  break;\n"
                "}\n"
+               "case 2: {\n"
+               "  break;\n"
+               "}\n"
                "}");
   verifyFormat("switch (x) {\n"
                "case 1: {\n"