[clang] [C] Diagnose use of C++ keywords in C (PR #137234)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 25 04:54:24 PDT 2025


AaronBallman wrote:

> > But the token kind we have is `identifier` and not one of the keywords, so we can't do the more trivial integer comparisons.
> 
> Can we precompute a list/map/whatever of all identifiers that are keywords in C++ but not in C and then do pointer comparisons on the `IdentifierInfo*` maybe? At least then we wouldn’t have to do actual string comparisons; that said, I’m not sure that’s going to be that much better...

That's a pretty good idea, let me try that. I'll back out the changes that disable checking when the diagnostic isn't enabled so we get a better comparison.

https://github.com/llvm/llvm-project/pull/137234


More information about the cfe-commits mailing list