[clang] [CIR] Upstream ArraySubscriptExpr for fixed size array (PR #134536)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 7 06:24:34 PDT 2025


================
@@ -232,6 +233,161 @@ LValue CIRGenFunction::emitUnaryOpLValue(const UnaryOperator *e) {
   llvm_unreachable("Unknown unary operator kind!");
 }
 
+/// If the specified expr is a simple decay from an array to pointer,
+/// return the array subexpression.
+/// FIXME: this could be abstracted into a commeon AST helper.
+static const Expr *isSimpleArrayDecayOperand(const Expr *e) {
+  // If this isn't just an array->pointer decay, bail out.
+  const auto *castExpr = dyn_cast<CastExpr>(e);
+  if (!castExpr || castExpr->getCastKind() != CK_ArrayToPointerDecay)
+    return nullptr;
+
+  // If this is a decay from variable width array, bail out.
+  const Expr *subExpr = castExpr->getSubExpr();
+  if (subExpr->getType()->isVariableArrayType())
----------------
erichkeane wrote:

Does this need an Assert/NYI/etc here? Seems like the purpose of MissingFeatures

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


More information about the cfe-commits mailing list