https://github.com/sweiglbosker created https://github.com/llvm/llvm-project/pull/138165
fixes: https://github.com/llvm/llvm-project/issues/138094 this patch fixes a crash triggered by Lexing past eof when emitting a diagnostic for a malformed `_Pragma` directive within an `include` directive. Fixed by by preventing the lexer from eating a `tok::eod`. >From 9841d71e3b0ebf22cb5ed96711a9519439caf62d Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker <ste...@s00.xyz> Date: Thu, 1 May 2025 12:24:17 -0400 Subject: [PATCH] [Lex] fix lexing malformed pragma within include directive --- clang/lib/Lex/Pragma.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp index 5b6a29bdad910..607e7b6a7dceb 100644 --- a/clang/lib/Lex/Pragma.cpp +++ b/clang/lib/Lex/Pragma.cpp @@ -220,11 +220,12 @@ void Preprocessor::Handle_Pragma(Token &Tok) { if (!tok::isStringLiteral(Tok.getKind())) { Diag(PragmaLoc, diag::err__Pragma_malformed); // Skip bad tokens, and the ')', if present. - if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof)) + if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof) && Tok.isNot(tok::eod)) Lex(Tok); while (Tok.isNot(tok::r_paren) && !Tok.isAtStartOfLine() && - Tok.isNot(tok::eof)) + Tok.isNot(tok::eof) && + Tok.isNot(tok::eod)) Lex(Tok); if (Tok.is(tok::r_paren)) Lex(Tok); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits