Fix crash on unmatched #endif's.
The following snippet would crash:
#endif
#if A
llvm-svn: 200381
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index efc563b..9b0a11c 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2427,6 +2427,11 @@
"#endif");
}
+TEST_F(FormatTest, GraciouslyHandleIncorrectPreprocessorConditions) {
+ verifyFormat("#endif\n"
+ "#if B");
+}
+
TEST_F(FormatTest, FormatsJoinedLinesOnSubsequentRuns) {
FormatStyle SingleLine = getLLVMStyle();
SingleLine.AllowShortIfStatementsOnASingleLine = true;