clang-format: Improve recovery from enums with errors.
Before:
namespace n {
enum Type {
One,
Two, // missing };
int i;
} void g() {
}
After:
namespace n {
enum Type {
One,
Two, // missing };
int i;
}
void g() {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189662 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 9c8efd8..aef1dae 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1519,6 +1519,20 @@
verifyFormat("enum X f() {\n a();\n return 42;\n}");
}
+TEST_F(FormatTest, FormatsEnumsWithErrors) {
+ verifyFormat("enum Type {\n"
+ " One = 0;\n" // These semicolons should be commas.
+ " Two = 1;\n"
+ "};");
+ verifyFormat("namespace n {\n"
+ "enum Type {\n"
+ " One,\n"
+ " Two,\n" // missing };
+ " int i;\n"
+ "}\n"
+ "void g() {}");
+}
+
TEST_F(FormatTest, FormatsEnumStruct) {
verifyFormat("enum struct {\n"
" Zero,\n"