aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/TokenAnnotator.cpp3
-rw-r--r--unittests/Format/FormatTest.cpp16
2 files changed, 12 insertions, 7 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index bb2e04b66e..d9368c3649 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -293,7 +293,8 @@ private:
next();
if (!parseAngle())
return false;
- CurrentToken->Parent->ClosesTemplateDeclaration = true;
+ if (CurrentToken != NULL)
+ CurrentToken->Parent->ClosesTemplateDeclaration = true;
return true;
}
return false;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index fb388ab7f9..3a1e9dce95 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -378,12 +378,6 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
verifyFormat("switch (test)\n"
" ;");
- // FIXME: Improve formatting of case labels in macros.
- verifyFormat("#define SOMECASES \\\n"
- "case 1: \\\n"
- " case 2\n",
- getLLVMStyleWithColumns(20));
-
verifyGoogleFormat("switch (x) {\n"
" case 1:\n"
" f();\n"
@@ -935,6 +929,16 @@ TEST_F(FormatTest, EmptyLinesInMacroDefinitions) {
getLLVMStyleWithColumns(11)));
}
+TEST_F(FormatTest, MacroDefinitionsWithIncompleteCode) {
+ // FIXME: Improve formatting of case labels in macros.
+ verifyFormat("#define SOMECASES \\\n"
+ "case 1: \\\n"
+ " case 2\n",
+ getLLVMStyleWithColumns(20));
+
+ verifyFormat("#define A template <typename T>");
+}
+
TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) {
EXPECT_EQ("{\n {\n#define A\n }\n}", format("{{\n#define A\n}}"));
}