r205611 - clang-format: Don't merge simple blocks in case statements.
Daniel Jasper
djasper at google.com
Thu Apr 3 23:46:26 PDT 2014
Author: djasper
Date: Fri Apr 4 01:46:23 2014
New Revision: 205611
URL: http://llvm.org/viewvc/llvm-project?rev=205611&view=rev
Log:
clang-format: Don't merge simple blocks in case statements.
Before:
switch (a) {
case 1: { return 'a'; }
}
After:
switch (a) {
case 1: {
return 'a';
}
}
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=205611&r1=205610&r2=205611&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Apr 4 01:46:23 2014
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=205611&r1=205610&r2=205611&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Apr 4 01:46:23 2014
@@ -511,6 +511,9 @@ TEST_F(FormatTest, FormatsSwitchStatemen
" f();\n"
" break;\n"
"}\n"
+ "case 2: {\n"
+ " break;\n"
+ "}\n"
"}");
verifyFormat("switch (x) {\n"
"case 1: {\n"
More information about the cfe-commits
mailing list