[clang] [clang] Fix crash on unterminated __identifier (PR #229156)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 14:59:48 PDT 2026


================
@@ -2034,12 +2034,14 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
     }
 
     // Discard the ')', preserving 'Tok' as our result.
-    Token RParen;
-    LexNonComment(RParen);
-    if (RParen.isNot(tok::r_paren)) {
+    Token Next;
+    LexNonComment(Next);
+    if (Next.isNot(tok::r_paren)) {
       Diag(getLocForEndOfToken(Tok.getLocation()), diag::err_pp_expected_after)
         << Tok.getKind() << tok::r_paren;
       Diag(LParenLoc, diag::note_matching) << tok::l_paren;
+      if (Next.isOneOf(tok::eof, tok::eod) || Next.isAnnotation())
----------------
shafik wrote:

If the `|| Next.isAnnotation()`  case tested below? If not it should be.

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


More information about the cfe-commits mailing list