<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97560>97560</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Typo correction lacks support for much of C
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c,
quality-of-implementation,
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AaronBallman
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlcFy2zgMhp-GvmDqkSlLlg86JM54t9PemnuHIiGLa4pUCCiu9-l3SNu1k-llL1EECeCHH79gRWQPHrEV1bOoXhZq5iHE9knF4J-Vc6Pyiy6Yc_u1h3OYwYVwBMXAA8IRz6cQDcEJQRkD1kOqUhdPxny7PnsNu-BpHjGKuhDVi5DNwDyRKJ-E3Au5P1ge5m6pwyjk3rn32-XLFMM_qFnIfedCJ-S-kf1WVZ3a1pXRK7UuetxWVdfIojKmqcuur8um0r2Qe-2UP6RCNiX-wFFdL99DOM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