[clang] [CIR] Upstream pointer arithmetic support (PR #138041)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 30 16:19:13 PDT 2025
================
@@ -1152,8 +1169,72 @@ getUnwidenedIntegerType(const ASTContext &astContext, const Expr *e) {
static mlir::Value emitPointerArithmetic(CIRGenFunction &cgf,
const BinOpInfo &op,
bool isSubtraction) {
- cgf.cgm.errorNYI(op.loc, "pointer arithmetic");
- return {};
+ // Must have binary (not unary) expr here. Unary pointer
+ // increment/decrement doesn't use this path.
+ const BinaryOperator *expr = cast<BinaryOperator>(op.e);
+
+ mlir::Value pointer = op.lhs;
+ Expr *pointerOperand = expr->getLHS();
+ mlir::Value index = op.rhs;
----------------
andykaylor wrote:
CIR has a dedicated `ptr_diff` operation so `pointer - pointer` won't go through here.
https://github.com/llvm/llvm-project/pull/138041
More information about the cfe-commits
mailing list