https://github.com/vtjnash created 
https://github.com/llvm/llvm-project/pull/203010

In https://reviews.llvm.org/D159247
(400d3261a0da56554aee8e5a2fbc27eade9d05db) it looks intended to update all of 
these calls, but missed this. The effect is that a reference to `this` in a 
non-zero addrspace would crash here (because it asserts that `this` is a 
pointer). DRY the code since this branch looks like it kept getting copied more 
incorrectly over time. I don't have an actual use or test for this, I just 
noticed it while I was trying to break other things in fuzzing.

>From c09aa9d5777350689000da935698bb51d809aaee Mon Sep 17 00:00:00 2001
From: Jameson Nash <[email protected]>
Date: Wed, 10 Jun 2026 15:02:51 +0000
Subject: [PATCH] [clang] `this` getter missed in ConstructAttributeList

In https://reviews.llvm.org/D159247
(400d3261a0da56554aee8e5a2fbc27eade9d05db) it looks intended to update
all of these calls, but missed this. The effect is that a reference to
`this` in a non-zero addrspace would crash here (because it asserts that
`this` is a pointer). DRY the code since this branch looks like it kept
getting copied more incorrectly over time.
---
 clang/lib/CodeGen/CGCall.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 40cc275d40273..09f6d63a36bd6 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2922,20 +2922,18 @@ void CodeGenModule::ConstructAttributeList(StringRef 
Name,
     llvm::AttrBuilder &Attrs = ArgAttrs[IRArgs.first];
 
     QualType ThisTy = FI.arg_begin()->type.getTypePtr()->getPointeeType();
+    int64_t ThisSz = getMinimumObjectSize(ThisTy).getQuantity();
 
     if (!CodeGenOpts.NullPointerIsValid &&
         getTypes().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
       Attrs.addAttribute(llvm::Attribute::NonNull);
-      Attrs.addDereferenceableAttr(getMinimumObjectSize(ThisTy).getQuantity());
+      Attrs.addDereferenceableAttr(ThisSz);
     } else {
       // FIXME dereferenceable should be correct here, regardless of
       // NullPointerIsValid. However, dereferenceable currently does not always
       // respect NullPointerIsValid and may imply nonnull and break the 
program.
       // See https://reviews.llvm.org/D66618 for discussions.
-      Attrs.addDereferenceableOrNullAttr(
-          getMinimumObjectSize(
-              FI.arg_begin()->type.castAs<PointerType>()->getPointeeType())
-              .getQuantity());
+      Attrs.addDereferenceableOrNullAttr(ThisSz);
     }
 
     llvm::Align Alignment =

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to