[clang] [HLSL] Codegen for indexing of sub-arrays of multi-dimensional resource arrays (PR #154248)

Alex Sepkowski via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 28 16:29:12 PDT 2025


================
@@ -802,16 +869,14 @@ std::optional<LValue> CGHLSLRuntime::emitResourceArraySubscriptExpr(
          ArraySubsExpr->getType()->isHLSLResourceRecordArray() &&
              "expected resource array subscript expression");
 
-  // let clang codegen handle local resource array subscripts
-  const VarDecl *ArrayDecl = dyn_cast<VarDecl>(getArrayDecl(ArraySubsExpr));
+  // Let clang codegen handle local resource array subscripts,
+  // or when the subscript references on opaque expression (as part of
+  // ArrayInitLoopExpr AST node).
+  const VarDecl *ArrayDecl =
+      dyn_cast_or_null<VarDecl>(getArrayDecl(ArraySubsExpr));
----------------
alsepkow wrote:

For learning purposes, when would the result of getArrayDecl ever be expected to be null? That seems weird to me in this case.

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


More information about the cfe-commits mailing list