[clang] [C++][Modules] A module directive may only appear as the first preprocessing tokens in a file (PR #144233)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 17 09:30:30 PDT 2025
================
@@ -3725,13 +3727,21 @@ bool Lexer::Lex(Token &Result) {
HasLeadingEmptyMacro = false;
}
+ if (IsFirstPPToken) {
+ Result.setFlag(Token::FirstPPToken);
+ IsFirstPPToken = false;
+ }
+
bool atPhysicalStartOfLine = IsAtPhysicalStartOfLine;
IsAtPhysicalStartOfLine = false;
bool isRawLex = isLexingRawMode();
(void) isRawLex;
bool returnedToken = LexTokenInternal(Result, atPhysicalStartOfLine);
// (After the LexTokenInternal call, the lexer might be destroyed.)
assert((returnedToken || !isRawLex) && "Raw lex must succeed");
+
+ if (returnedToken && Result.isFirstPPToken() && PP)
+ PP->setFirstPPToken(Result);
----------------
yronglin wrote:
Fixed
https://github.com/llvm/llvm-project/pull/144233
More information about the cfe-commits
mailing list