[clang] [Clang][CodeGen] Do not set inbounds flag in `EmitMemberDataPointerAddress` when the base pointer is null (PR #130952)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 10 16:50:53 PDT 2025
================
@@ -660,8 +660,8 @@ EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *M) {
case SubobjectAdjustment::MemberPointerAdjustment: {
llvm::Value *Ptr = EmitScalarExpr(Adjustment.Ptr.RHS);
- Object = EmitCXXMemberDataPointerAddress(E, Object, Ptr,
- Adjustment.Ptr.MPT);
+ Object = EmitCXXMemberDataPointerAddress(
+ E, Object, Ptr, Adjustment.Ptr.MPT, /*IsInBounds=*/true);
----------------
efriedma-quic wrote:
This sent me down a really deep rabbit-hole to figure out when this code actually runs... apparently, in C++98 mode, we delay creating temporaries for things that would be xvalues in newer standard versions, and then we try to fix things up later using skipRValueSubobjectAdjustments(). We don't have an in-tree tests for this particular codepath. The whole thing is really ugly, and we should really come up with a better solution...
In any case, the base object should be an alloca here, so inbounds should be fine.
https://github.com/llvm/llvm-project/pull/130952
More information about the cfe-commits
mailing list