Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc-const-correctness not reported for C code #56958

Open
firewave opened this issue Aug 5, 2022 · 4 comments
Open

misc-const-correctness not reported for C code #56958

firewave opened this issue Aug 5, 2022 · 4 comments

Comments

@firewave
Copy link

firewave commented Aug 5, 2022

extern int cb();

void f1()
{
    int res = cb(); // no warning
    if (res) {}
}

https://godbolt.org/z/Tzrb1Yvxq

The documentation refers to C++ coding standards but there's no mention that the check will only be performed on C++ code.

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 5, 2022

@llvm/issue-subscribers-clang-tidy

@njames93
Copy link
Member

njames93 commented Aug 5, 2022

@JonasToth I feel like a quick fix is to just update the documentation to say this doesn't run on C code. Then we can look into adapting to make it work for C code, which I imagine is just a case of adding test cases and removing the language restriction.

@JonasToth
Copy link
Member

The language restriction was added during review. const works different enough in C that it was removed.
I will provide a documentation update as known limitation

@JonasToth
Copy link
Member

@njames93 i included the limitation in this patch: https://reviews.llvm.org/D132244
That is the separation of the documentation changes done for #56749

JonasToth added a commit that referenced this issue Aug 29, 2022
Improve the documentation for 'misc-const-correctness' to:

- include better examples
- improve the english
- fix links to other checks that were broken due to the directory-layout changes
- mention the limitation that the check does not run on `C` code.

Addresses #56749, #56958

Reviewed By: njames93

Differential Revision: https://reviews.llvm.org/D132244
tru pushed a commit that referenced this issue Sep 30, 2022
Improve the documentation for 'misc-const-correctness' to:

- include better examples
- improve the english
- fix links to other checks that were broken due to the directory-layout changes
- mention the limitation that the check does not run on `C` code.

Addresses #56749, #56958

Reviewed By: njames93

Differential Revision: https://reviews.llvm.org/D132244

(cherry picked from commit b5b7503)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants