File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -1825,12 +1825,13 @@ The following type trait primitives are supported by Clang. Those traits marked
1825
1825
* ``__is_trivially_relocatable `` (Clang): Returns true if moving an object
1826
1826
of the given type, and then destroying the source object, is known to be
1827
1827
functionally equivalent to copying the underlying bytes and then dropping the
1828
- source object on the floor. This is true of trivial types and types which
1828
+ source object on the floor. This is true of trivial types,
1829
+ C++26 relocatable types, and types which
1829
1830
were made trivially relocatable via the ``clang::trivial_abi `` attribute.
1830
1831
* ``__builtin_is_cpp_trivially_relocatable `` (C++): Returns true if an object
1831
1832
is trivially relocatable, as defined by the C++26 standard [meta.unary.prop].
1832
- Note that the caller code should ensure that if the object is polymorphic,
1833
- the dynamic type is of the most derived type.
1833
+ Note that when relocating the caller code should ensure that if the object is polymorphic,
1834
+ the dynamic type is of the most derived type. Padding bytes should not be copied.
1834
1835
* ``__builtin_is_replaceable `` (C++): Returns true if an object
1835
1836
is replaceable, as defined by the C++26 standard [meta.unary.prop].
1836
1837
* ``__is_trivially_equality_comparable `` (Clang): Returns true if comparing two
Original file line number Diff line number Diff line change @@ -2848,7 +2848,7 @@ bool QualType::isTriviallyRelocatableType(const ASTContext &Context) const {
2848
2848
return false ;
2849
2849
} else if (const auto *RD = BaseElementType->getAsRecordDecl ()) {
2850
2850
return RD->canPassInRegisters ();
2851
- } else if (BaseElementType.isTriviallyCopyableType (Context)) {
2851
+ } else if (BaseElementType.isCppTriviallyRelocatableType (Context)) {
2852
2852
return true ;
2853
2853
} else {
2854
2854
switch (isNonTrivialToPrimitiveDestructiveMove ()) {
@@ -2864,10 +2864,16 @@ bool QualType::isTriviallyRelocatableType(const ASTContext &Context) const {
2864
2864
2865
2865
bool QualType::isCppTriviallyRelocatableType (const ASTContext &Context) const {
2866
2866
QualType BaseElementType = Context.getBaseElementType (*this );
2867
+
2868
+ if (hasNonTrivialObjCLifetime ())
2869
+ return false ;
2870
+
2867
2871
if (BaseElementType->isIncompleteType ())
2868
2872
return false ;
2869
- if (BaseElementType->isScalarType ())
2873
+
2874
+ if (BaseElementType->isScalarType () || BaseElementType->isVectorType ())
2870
2875
return true ;
2876
+
2871
2877
if (const auto *RD = BaseElementType->getAsCXXRecordDecl ())
2872
2878
return RD->isTriviallyRelocatable ();
2873
2879
return false ;
You can’t perform that action at this time.
0 commit comments