llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Stefan (sweiglbosker)

<details>
<summary>Changes</summary>

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`.

---
Full diff: https://github.com/llvm/llvm-project/pull/138165.diff


1 Files Affected:

- (modified) clang/lib/Lex/Pragma.cpp (+3-2) 


``````````diff
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);

``````````

</details>


https://github.com/llvm/llvm-project/pull/138165
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to