[Syntax] Fix a crash when dumping empty token buffer
llvm-svn: 363801
diff --git a/clang/unittests/Tooling/Syntax/TokensTest.cpp b/clang/unittests/Tooling/Syntax/TokensTest.cpp
index 34c80fc..a812b84 100644
--- a/clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -290,6 +290,14 @@
# pragma GCC visibility push ( public ) # pragma GCC visibility pop
mappings:
['#'_0, '<eof>'_13) => ['<eof>'_0, '<eof>'_0)
+)"},
+ // Empty files should not crash.
+ {R"cpp()cpp", R"(expanded tokens:
+ <empty>
+file './input.cpp'
+ spelled tokens:
+ <empty>
+ no mappings.
)"}};
for (auto &Test : TestCases)
EXPECT_EQ(collectAndDump(Test.first), Test.second)