[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Wed May 29 06:53:55 PDT 2024


hokein wrote:

> Could we rewrite the description and documentation to capture what the type trait is doing now? We have a lot of references to the `is_trivially_copyable`, which is almost fully irrelevant to the current implementation.

Thanks, I updated the PR description and documentation in the code, please take a look again.
I think it is worth to mentioning the `is_trivially_copyable`, they're conceptually relevant (users use `is_trivially_copyable` as a safe guard for `memcpy`).

> Also, is there a _simple_ way to make this work with the corresponding sanitizer? If not or it requires too much work, we could definitely return false here. Just making sure we explored this.

This doesn't scale well. There are a few sanitizers (asan, msan etc), and each sanitizer has their own version of memcpy. It is non-trivial to check all sanitizers to ensure all of them work properly. And it doesn't solve types with non-trivial  ObjectiveC lifetime.
 



https://github.com/llvm/llvm-project/pull/86512


More information about the cfe-commits mailing list