[clang-tools-extra] [clang-tidy] Create bugprone-bit-cast-pointers check (PR #108083)
Carlos Galvez via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 27 01:21:04 PDT 2024
carlosgalvezp wrote:
> > It now comes to mind that we probably also want to check `memcpy(ptr, ptr)`, which is equivalent to `bit_cast`. In that case I wonder if the check name still holds or it should be named something else?
>
> Yeah, with the addition of `memcpy`, the `bit` part of the name makes a less sense. Maybe
>
> * `bugprone-pointer-cast[ing]`
> * `bugprone-cast[ing]-between-pointers`
Hmm, I think "pointer cast" is too ambiguous, it could warn about _any_ type of pointer cast via e.g. `reinterpret_cast`, `const_cast`, etc. I want to put emphasis on the act of _copying the bytes_ of the pointer into another pointer to perform such a cast. In that sense I think "bit_cast" is still a more accurate name.
https://github.com/llvm/llvm-project/pull/108083
More information about the cfe-commits
mailing list