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

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 20 21:52:33 PST 2025


================
@@ -2862,6 +2862,30 @@ bool QualType::isTriviallyRelocatableType(const ASTContext &Context) const {
   }
 }
 
+bool QualType::isCppTriviallyRelocatableType(const ASTContext &Context) const {
+  QualType BaseElementType = Context.getBaseElementType(*this);
+  if (BaseElementType->isIncompleteType())
+    return false;
+  else if (BaseElementType->isScalarType())
+    return true;
+  else if (const auto *RD = BaseElementType->getAsCXXRecordDecl())
+    return RD->isTriviallyRelocatable();
----------------
zyn0217 wrote:

```suggestion
  if (BaseElementType->isScalarType())
    return true;
  if (const auto *RD = BaseElementType->getAsCXXRecordDecl())
    return RD->isTriviallyRelocatable();
```

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


More information about the cfe-commits mailing list