[clang] [clang] Guard identifier reads in pragma handlers (PR #230927)
Yihan Wang via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 20 22:02:57 PDT 2026
================
@@ -101,17 +101,23 @@ void PragmaNamespace::RemovePragmaHandler(PragmaHandler *Handler) {
Handlers.erase(I);
}
+// Names may be C++ operator keywords, which have punctuator token kinds.
+static IdentifierInfo *getPragmaIdentifierInfo(const Token &Tok) {
+ if (Tok.isAnnotation() || Tok.is(tok::raw_identifier))
----------------
yronglin wrote:
This might be missing if early return without any diagnostic:
```
if (!Handler) {
PP.Diag(Tok, diag::warn_pragma_ignored);
return;
}
```
Without an IdentifierInfo, clang cannot find a suitable handler for the pragma directive. Please correct me if I have missed any other scenarios.
https://github.com/llvm/llvm-project/pull/230927
More information about the cfe-commits
mailing list