From 3116d60494f219bfcb284d05d9ebed5b6c196ca5 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Mon, 21 Aug 2023 12:41:56 +0200 Subject: [Lex] Introduce Preprocessor::LexTokensUntilEOF() This new method repeatedly calls Lex() until end of file is reached and optionally fills a std::vector of Tokens. Use it in Clang's unit tests to avoid quite some code duplication. Differential Revision: https://reviews.llvm.org/D158413 --- clang/unittests/Lex/ModuleDeclStateTest.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'clang/unittests/Lex/ModuleDeclStateTest.cpp') diff --git a/clang/unittests/Lex/ModuleDeclStateTest.cpp b/clang/unittests/Lex/ModuleDeclStateTest.cpp index ed69438..15306ba 100644 --- a/clang/unittests/Lex/ModuleDeclStateTest.cpp +++ b/clang/unittests/Lex/ModuleDeclStateTest.cpp @@ -90,12 +90,7 @@ protected: PP.addPPCallbacks(std::move(C)); PP.EnterMainSourceFile(); - while (1) { - Token tok; - PP.Lex(tok); - if (tok.is(tok::eof)) - break; - } + PP.LexTokensUntilEOF(); } FileSystemOptions FileMgrOpts; -- cgit v1.1