[clang] [CIR] Upstream ArraySubscriptExpr from function parameter with pointer base (PR #135493)

Amr Hesham via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 14 11:20:49 PDT 2025


================
@@ -570,9 +570,17 @@ CIRGenFunction::emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e) {
   }
 
   // The base must be a pointer; emit it with an estimate of its alignment.
-  cgm.errorNYI(e->getSourceRange(),
-               "emitArraySubscriptExpr: The base must be a pointer");
-  return {};
+  assert(e->getBase()->getType()->isPointerType() &&
+         "The base must be a pointer");
+
+  LValueBaseInfo eltBaseInfo;
+  const Address ptrAddr = emitPointerWithAlignment(e->getBase(), &eltBaseInfo);
+  // Propagate the alignment from the array itself to the result.
----------------
AmrDeveloper wrote:

I think yes, I should keep it as lambda for the bounds checks in the future, I was thinking also of keeping it as a function but for now i will keep `emitIdxAfterBase`

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


More information about the cfe-commits mailing list