| Issue |
97560
|
| Summary |
Typo correction lacks support for much of C
|
| Labels |
c,
quality-of-implementation,
clang:diagnostics
|
| Assignees |
|
| Reporter |
AaronBallman
|
If you look at the keywords we add in [`AddKeywordsToConsumer`](https://github.com/llvm/llvm-project/blob/82f9a5ba965dc1a40fe955b8205dd863bf6385cf/clang/lib/Sema/SemaLookup.cpp#L4966), you'll see we are missing quite a few: `_Generic`, `_BitInt`, `_Static_assert`, `_Thread_local`, `nullptr`, `constexpr`, etc are all missing and this shows up in our typo correction behavior: https://godbolt.org/z/9nsKKc4sq
However, it's not a simple matter of adding the keywords to the consumer. Clang supports implicit function declarations in C versions before C23, so `_Genreic(` in an _expression_ context is handled as though the user called an undeclared function rather than an unknown id _expression_. Similar for `_BitInt` and `_Static_assert`. Further, the typo filter for declaration contexts uses heuristics to determine whether something is a statement or a declaration, and so it doesn't correctly handle `_Thrd_local int i` because the token after the typo `_Thrd_local` is `int` and not an identifier. This means `static _Thrd_local int i` can correct the typo because the leading `static` makes it clear that's a declaration and not a statement, but `_Thrd_local static int i;` cannot correct the typo.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs