[clang] [clang] Fix crash on unterminated __identifier (PR #229156)
Ambrose Leeb via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 7 13:52:36 PDT 2026
================
@@ -2040,6 +2040,10 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
Diag(getLocForEndOfToken(Tok.getLocation()), diag::err_pp_expected_after)
<< Tok.getKind() << tok::r_paren;
Diag(LParenLoc, diag::note_matching) << tok::l_paren;
+ // Don't lose an eod, eof, or annotation token while recovering from
+ // a missing ')'. Return it to the caller instead.
+ if (RParen.isOneOf(tok::eof, tok::eod) || RParen.isAnnotation())
+ Tok = RParen;
----------------
Sirraide wrote:
```suggestion
if (RParen.isOneOf(tok::eof, tok::eod) || RParen.isAnnotation())
Tok = RParen;
```
I think the comment doesn’t really add anything here. Also, can you rename `RParen` to `Next` or sth like that because it’s really confusing that it’s called `RParen` given that we have code here that explicitly handles the case of it _not_ being a `)` token
https://github.com/llvm/llvm-project/pull/229156
More information about the cfe-commits
mailing list