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

Amirreza Ashouri via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 20 08:05:15 PDT 2023


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

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

>From 64335289e35c4985ff83c5e07a6e951d04822cac Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri <ar.ashouri999 at gmail.com>
Date: Sat, 7 Oct 2023 15:18:55 +0330
Subject: [PATCH] [clang] Non-object types are non-trivially relocatable

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
---
 clang/lib/AST/Type.cpp | 2 ++
 1 file changed, 2 insertions(+)

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 {



More information about the cfe-commits mailing list