[clang] [Clang][CodeGen] Check `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic` (PR #137849)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 30 12:49:06 PDT 2025
================
@@ -4238,7 +4238,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
else
elemTy = CGF.ConvertTypeForMem(elementType);
- if (CGF.getLangOpts().PointerOverflowDefined)
+ if (CGF.getLangOpts().PointerOverflowDefined ||
+ CGF.isUnderlyingBasePointerConstantNull(pointerOperand))
----------------
efriedma-quic wrote:
I guess it's fine to have different workarounds given the context isn't the same, but I'd like a comment in the code explaining the relationship between the two checks, at least.
https://github.com/llvm/llvm-project/pull/137849
More information about the cfe-commits
mailing list