aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Lex/LexerTest.cpp
diff options
context:
space:
mode:
authorJonas Hahnfeld <jonas.hahnfeld@cern.ch>2023-08-21 12:41:56 +0200
committerJonas Hahnfeld <jonas.hahnfeld@cern.ch>2023-10-05 11:04:07 +0200
commit3116d60494f219bfcb284d05d9ebed5b6c196ca5 (patch)
tree4098e5aead4239f84f7930b67822c2f90a37e9a1 /clang/unittests/Lex/LexerTest.cpp
parent7fa33773e355aaef03197e19698303748238d91a (diff)
downloadllvm-3116d60494f219bfcb284d05d9ebed5b6c196ca5.zip
llvm-3116d60494f219bfcb284d05d9ebed5b6c196ca5.tar.gz
llvm-3116d60494f219bfcb284d05d9ebed5b6c196ca5.tar.bz2
[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
Diffstat (limited to 'clang/unittests/Lex/LexerTest.cpp')
-rw-r--r--clang/unittests/Lex/LexerTest.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/clang/unittests/Lex/LexerTest.cpp b/clang/unittests/Lex/LexerTest.cpp
index 8932265..47aa2c1 100644
--- a/clang/unittests/Lex/LexerTest.cpp
+++ b/clang/unittests/Lex/LexerTest.cpp
@@ -74,13 +74,7 @@ protected:
PP = CreatePP(Source, ModLoader);
std::vector<Token> toks;
- while (1) {
- Token tok;
- PP->Lex(tok);
- if (tok.is(tok::eof))
- break;
- toks.push_back(tok);
- }
+ PP->LexTokensUntilEOF(&toks);
return toks;
}
@@ -628,12 +622,7 @@ TEST_F(LexerTest, FindNextToken) {
TEST_F(LexerTest, CreatedFIDCountForPredefinedBuffer) {
TrivialModuleLoader ModLoader;
auto PP = CreatePP("", ModLoader);
- while (1) {
- Token tok;
- PP->Lex(tok);
- if (tok.is(tok::eof))
- break;
- }
+ PP->LexTokensUntilEOF();
EXPECT_EQ(SourceMgr.getNumCreatedFIDsForFileID(PP->getPredefinesFileID()),
1U);
}