Skip to content

Typo correction lacks support for much of C #97560

Open
@AaronBallman

Description

@AaronBallman

If you look at the keywords we add in AddKeywordsToConsumer, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerquality-of-implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions