From: Daniel Jasper Date: Fri, 4 Apr 2014 06:46:23 +0000 (+0000) Subject: clang-format: Don't merge simple blocks in case statements. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=261a28e368fef81bd16faddb2e741e33ad677b41;p=clang clang-format: Don't merge simple blocks in case statements. 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 --- diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index cb07cb56a5..44116a8f8e 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 76062605f7..90e6ff7203 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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"