[clang] [clang] Non-object types are non-trivially relocatable (PR #69734)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 20 08:06:55 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Amirreza Ashouri (AMP999)

<details>
<summary>Changes</summary>

Both active C++ proposals (P1144 and P2786) agree that `is_trivially_relocatable_v<int&>` and `is_trivially_relocatable_v<int()>` should be false, not true. Only complete object types can be trivially relocatable.

Fixes #<!-- -->67498

---
Full diff: https://github.com/llvm/llvm-project/pull/69734.diff


1 Files Affected:

- (modified) clang/lib/AST/Type.cpp (+2) 


``````````diff
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 8389b1423058197..bdeff1e4ac5b604 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2649,6 +2649,8 @@ bool QualType::isTriviallyRelocatableType(const ASTContext &Context) const {
 
   if (BaseElementType->isIncompleteType()) {
     return false;
+  } else if (!BaseElementType->isObjectType()) {
+    return false;
   } else if (const auto *RD = BaseElementType->getAsRecordDecl()) {
     return RD->canPassInRegisters();
   } else {

``````````

</details>


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


More information about the cfe-commits mailing list