[clang] 59e18f4 - [clang] `this` getter missed in ConstructAttributeList (#203010)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 11 05:59:58 PDT 2026
Author: Jameson Nash
Date: 2026-06-11T08:59:53-04:00
New Revision: 59e18f41b35de71799ad8f2f615e3c01bac86e1e
URL: https://github.com/llvm/llvm-project/commit/59e18f41b35de71799ad8f2f615e3c01bac86e1e
DIFF: https://github.com/llvm/llvm-project/commit/59e18f41b35de71799ad8f2f615e3c01bac86e1e.diff
LOG: [clang] `this` getter missed in ConstructAttributeList (#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 `&this` in a non-zero addrspace would take
this branch and crash there (because it ends up asserting 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.
Added:
Modified:
clang/lib/CodeGen/CGCall.cpp
Removed:
################################################################################
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 =
More information about the cfe-commits
mailing list