https://github.com/yronglin created https://github.com/llvm/llvm-project/pull/173052
This patch fix a bug introduced by https://github.com/llvm/llvm-project/pull/107168. Consider the following code: ```c #define str(s) # s #define xstr(s) str(s) #define INCFILE(n) vers ## n include xstr(INCFILE(2).h) ``` The period has an unexpected `AtStartOfLine` flag when it's lexed from `TokenLexer`, after phase 4, we expected `include "vers2.h"`, but got `include "vers2 .h"`, an unexpected whitespace occurred before `.`. We only need to propagate `AtStartOfLine` flag when current `TokenLexer` expanding an token stream. >From 7ef806b6e2d3634b793f46ba16cf9dfeb6cc640f Mon Sep 17 00:00:00 2001 From: yronglin <[email protected]> Date: Sat, 20 Dec 2025 01:25:00 +0800 Subject: [PATCH] [clang] Only propagated AtStartOfLine when expanding token stream and hit the end of TokenLexer Signed-off-by: yronglin <[email protected]> --- clang/lib/Lex/TokenLexer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index e9531ee9794d2..ce072de79b6af 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/lib/Lex/TokenLexer.cpp @@ -632,7 +632,7 @@ bool TokenLexer::Lex(Token &Tok) { // // The 'extern' token should has 'StartOfLine' flag when current TokenLexer // exits and propagate line start/leading space info. - if (isLexingCXXModuleDirective()) { + if (!Macro && isLexingCXXModuleDirective()) { AtStartOfLine = true; setLexingCXXModuleDirective(false); } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
