[clang] [Clang][CodeGen] Move `EmitPointerArithmetic` into `CodeGenFunction`. NFC. (PR #152634)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 8 00:23:16 PDT 2025


================
@@ -4227,79 +4234,77 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
   //
   // Note that we do not suppress the pointer overflow check in this case.
   if (BinaryOperator::isNullPointerArithmeticExtension(
-          CGF.getContext(), op.Opcode, expr->getLHS(), expr->getRHS())) {
-    Value *Ptr = CGF.Builder.CreateIntToPtr(index, pointer->getType());
-    if (CGF.getLangOpts().PointerOverflowDefined ||
-        !CGF.SanOpts.has(SanitizerKind::PointerOverflow) ||
-        NullPointerIsDefined(CGF.Builder.GetInsertBlock()->getParent(),
+          getContext(), BO->getOpcode(), BO->getLHS(), BO->getRHS())) {
----------------
nikic wrote:

Should this be?
```suggestion
          getContext(), BO->getOpcode(), pointerOperand, indexOperand)) {
```

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


More information about the cfe-commits mailing list