[clang] [clang] Bounds checking on unclosed parentheses, brackets or braces in Expanded Tokens (PR #69849)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 8 02:44:34 PST 2024


ilya-biryukov wrote:

I second everything that @HighCommander4 said. It would be really useful to add an assertion that we never get out-of-bounds here, but this indicates a logic error somewhere in the code that should be fixed.

I am slightly suspicious of source locations pointing at `eof` in the AST in the first place, even in invalid code. I wonder if we would be better off just having an invalid source location there instead of pointing at `eof`.

Asserting that `tok::eof` should not be passed to `spelledForExpandedToken` and returning `nullopt` in `spelledForExpanded` looks like a reasonable workaround until we fix this. (The semantics looks reasonable as we don't really have a spelled token we can map `eof` back to).

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


More information about the cfe-commits mailing list