[PATCH] D158414: [LexerTest] Use LexAll() in StringifyArgs
Jonas Hahnfeld via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 21 05:09:01 PDT 2023
Hahnfeld created this revision.
Hahnfeld added a reviewer: erichkeane.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Rely on `Preprocessor::LexAll()` and just replace `tok::comma` by `tok::eof` and push a `tok::eof` as the last element.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158414
Files:
clang/unittests/Lex/LexerTest.cpp
Index: clang/unittests/Lex/LexerTest.cpp
===================================================================
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -447,19 +447,15 @@
Token Eof;
Eof.setKind(tok::eof);
- std::vector<Token> ArgTokens;
- while (1) {
- Token tok;
- PP->Lex(tok);
- if (tok.is(tok::eof)) {
- ArgTokens.push_back(Eof);
- break;
+ std::vector<Token> ArgTokens = PP->LexAll();
+ // Replace all tok::comma with tok::eof for stringification.
+ for (auto &tok : ArgTokens) {
+ if (tok.is(tok::comma)) {
+ tok = Eof;
}
- if (tok.is(tok::comma))
- ArgTokens.push_back(Eof);
- else
- ArgTokens.push_back(tok);
}
+ // Push a tok::eof as the last element.
+ ArgTokens.push_back(Eof);
auto MacroArgsDeleter = [&PP](MacroArgs *M) { M->destroy(*PP); };
std::unique_ptr<MacroArgs, decltype(MacroArgsDeleter)> MA(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158414.551991.patch
Type: text/x-patch
Size: 924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230821/1f02a2b2/attachment-0001.bin>
More information about the cfe-commits
mailing list