[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

Nikolas Klauser via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 25 05:13:40 PST 2025


================
@@ -1826,6 +1827,12 @@ The following type trait primitives are supported by Clang. Those traits marked
   functionally equivalent to copying the underlying bytes and then dropping the
   source object on the floor. This is true of trivial types and types which
   were made trivially relocatable via the ``clang::trivial_abi`` attribute.
+* ``__builtin_is_cpp_trivially_relocatable`` (C++): Returns true if an object
+  is trivially relocatable, as defined by the C++26 standard [meta.unary.prop].
+  Note that the caller code should ensure that if the object is polymorphic,
+  the dynamic type is of the most derived type.
----------------
philnik777 wrote:

I'm not sure I understand what breakage you're afraid of. Sure, a deprecation warning would break stuff with `-Werror`, but that's nothing new. I'm not saying we should make `__is_trivially_relocatable` return false if only `[[clang::trivial_abi]]` is added. I'm saying we should fix the users code and warn (and eventually error) if they're not giving us the guarantee. I just don't see when we'd ever want to use `__is_cpp_trivially_relocatable` over `__is_trivially_relocatable`.

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


More information about the cfe-commits mailing list