[clang] [Clang] prevent assertion in __has_embed parameter recovery at end-of-directive (PR #175104)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 9 02:36:34 PST 2026
================
@@ -3686,14 +3686,14 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) {
std::pair<tok::TokenKind, SourceLocation> Matches) {
Diag(CurTok, diag::err_expected) << Expected;
Diag(Matches.second, diag::note_matching) << Matches.first;
- if (CurTok.isNot(EndTokenKind))
----------------
a-tarasyuk wrote:
@shafik Thanks for the feedback. `LexEmbedParameters` is shared by `#embed` and `__has_embed(...)`, so `EndTokenKind` is still required to terminate normal parsing appropriately.
This change only affects error recovery. `DiscardUntilEndOfDirective` is specifically intended to skip the remainder of the directive line, so once `CurTok` is already `tok::eod`, there is nothing left to discard, and the context-specific expected end token (e.g., `tok::r_paren` for `__has_embed`) is no longer relevant.
The added tests cover this behavior. Other scenarios appear to be handled by the existing `embed___has_embed_parsing_errors` tests; if there are additional edge cases to cover, please let me know.
https://github.com/llvm/llvm-project/pull/175104
More information about the cfe-commits
mailing list