Fixes recovering from errors when parsing braced init lists.
Before we would build huge unwrapped lines which take a long time
to optimze.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179168 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index fbde283..5b5f483 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -3734,5 +3734,19 @@
format("R\"(\\x\\x00)\"\n", getLLVMStyleWithColumns(7)));
}
+TEST_F(FormatTest, DoNotCreateUnreasonableUnwrappedLines) {
+ verifyFormat("void f() {\n"
+ " return g() {}\n"
+ " void h() {}");
+ verifyFormat("if (foo)\n"
+ " return { forgot_closing_brace();\n"
+ "test();");
+ verifyFormat("int a[] = { void forgot_closing_brace()\n"
+ "{\n"
+ " f();\n"
+ " g();\n"
+ "}");
+}
+
} // end namespace tooling
} // end namespace clang