================ @@ -816,6 +816,18 @@ TEST_F(TokenBufferTest, SpelledByExpanded) { EXPECT_EQ(Buffer.spelledForExpanded(findExpanded("prev good")), std::nullopt); } +TEST_F(TokenBufferTest, NoCrashForEofToken) { + recordTokens(R"cpp( + int main() { + )cpp"); + // Calling spelledForExpanded() on the entire range of expanded tokens (which + // includes the `eof` token at the end) produces the range of all the spelled + // tokens (the `eof` is ignored). + EXPECT_THAT( ---------------- ilya-biryukov wrote:
NIT: it's redundant, but for documentation purposes I suggest to add a sanity check: ```cpp ASSERT(!Buffers.expandedToken().empty()); ASSERT_EQ(Buffers.expandedToken().back().kind(), tok::eof); ``` This should allow to shorten the comment above a bit too. But also feel free to leave as is. https://github.com/llvm/llvm-project/pull/78092 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits