auto DumpTokens = [this, &PrintToken](llvm::raw_ostream &OS,
llvm::ArrayRef<syntax::Token> Tokens) {
- if (Tokens.size() == 1) {
- assert(Tokens[0].kind() == tok::eof);
+ if (Tokens.empty()) {
OS << "<empty>";
return;
}
OS << "expanded tokens:\n"
<< " ";
- DumpTokens(OS, ExpandedTokens);
+ // (!) we do not show '<eof>'.
+ DumpTokens(OS, llvm::makeArrayRef(ExpandedTokens).drop_back());
OS << "\n";
std::vector<FileID> Keys;
# 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)