[clang] [clang][Lex] Diagnose keywords in macro expansions (PR #242626)

Chen Miao via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 01:02:21 PST 2026


================
@@ -570,6 +570,9 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
           if (NewMI != MI || MI->isFunctionLike())
             Diag(Identifier, diag::pp_disabled_macro_expansion);
         }
+      // Fast expansion bypasses TokenLexer and its call to HandleIdentifier.
----------------
ChenMiaoi wrote:

``` cc
#define constexpr constexpr
int constexpr;
```

For example, if the token has already been marked as ineligible for further expansion(`Identifier.setFlag(Token::DisableExpand)`), calling `HandleIdentifier` here would emit an extra recursion warning.

So, I do the helper function.

https://github.com/llvm/llvm-project/pull/242626


More information about the cfe-commits mailing list