[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143796)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 12 02:01:22 PDT 2025


================
@@ -292,77 +294,129 @@ Sema::CheckCXX2CRelocatableAndReplaceable(const CXXRecordDecl *D) {
       return HasSuitableSMP();
 
     // is a union with no user-declared special member functions, or
-    if (IsUnion())
+    if (IsTrivialUnion())
       return HasSuitableSMP();
 
     // is default-movable.
     return IsDefaultMovable();
   }();
 
+  bool PtrauthMatters = LangOpts.PointerAuthIntrinsics ||
+                        LangOpts.PointerAuthVTPtrAddressDiscrimination;
+  if (PtrauthMatters) {
+    bool IsUnion = D->isUnion();
+    auto RecordPointerAuth = [&](bool HasAddressDiscrimination) {
+      if (HasAddressDiscrimination && IsUnion) {
+        Info.IsRelocatable = false;
+        Info.IsReplaceable = false;
+      }
+    };
+    auto IsBottomRelocationInfo = [](const CXXRecordDeclRelocationInfo &Info) {
----------------
ojhunt wrote:

Yeah, I really wasn't sure what to call it

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


More information about the cfe-commits mailing list