clang-format: Don't merge short else blocks.
Before (with the appropriate flags settings):
if (a) {
f();
} else { g(); }
Before (with other appropriate flags settings):
if (a) { f(); } else {
g();
}
After:
if (a) {
f();
} else {
g();
}
llvm-svn: 236217
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 9f34004..e2db4d1 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -416,6 +416,12 @@
" f();\n"
"}",
AllowSimpleBracedStatements);
+ verifyFormat("if (true) {\n"
+ " f();\n"
+ "} else {\n"
+ " f();\n"
+ "}",
+ AllowSimpleBracedStatements);
verifyFormat("template <int> struct A2 {\n"
" struct B {};\n"
@@ -427,6 +433,12 @@
" f();\n"
"}",
AllowSimpleBracedStatements);
+ verifyFormat("if (true) {\n"
+ " f();\n"
+ "} else {\n"
+ " f();\n"
+ "}",
+ AllowSimpleBracedStatements);
AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = false;
verifyFormat("while (true) {\n"