[clang] [Clang] [C++26] P1306R5: Iterating expansion statements using string injection (PR #208877)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 5 01:54:19 PDT 2026
================
@@ -573,6 +573,22 @@ Module *Preprocessor::getCurrentModuleImplementation() {
return getHeaderSearchInfo().lookupModule(getLangOpts().ModuleName);
}
+bool Preprocessor::LexTokensInString(SmallVectorImpl<Token> &Tokens,
+ StringRef Code, SourceLocation Loc) {
+ std::unique_ptr<Lexer> L = Lexer::CreateScratchLexer(Code, Loc, Loc, *this);
+ L->ProduceEOFWhenDone = true; // Stop lexing once 'L' is done.
+ EnterSourceFileWithLexer(std::move(L), nullptr);
+ for (;;) {
+ Token Tok;
+ Lex(Tok);
+ if (Tok.is(tok::unknown))
+ return true;
+ if (Tok.is(tok::eof))
+ return false;
+ Tokens.push_back(Tok);
+ }
+}
+
----------------
cor3ntin wrote:
Can you try that?
https://github.com/llvm/llvm-project/pull/208877
More information about the cfe-commits
mailing list