[llvm-branch-commits] [clang] [HLSL] Add implicit binding attribute to resource arrays (PR #152452)

Helena Kotas via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 7 13:51:21 PDT 2025


================
@@ -342,6 +346,17 @@ static bool isResourceRecordTypeOrArrayOf(VarDecl *VD) {
   return Ty->isHLSLResourceRecord() || Ty->isHLSLResourceRecordArray();
 }
 
+static const HLSLAttributedResourceType *
+getResourceArrayHandleType(VarDecl *VD) {
+  assert(VD->getType()->isHLSLResourceRecordArray() &&
+         "expected array of resource records");
+  const Type *Ty = VD->getType()->getUnqualifiedDesugaredType();
+  while (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty)) {
+    Ty = CAT->getArrayElementTypeNoTypeQual()->getUnqualifiedDesugaredType();
+  }
----------------
hekota wrote:

It is grabbing the array element type (=the actual resource type). Multi-dimensional arrays are represented by nested `ConstantArrayType`s instances, so to get to the element type the array type needs to be "unwrapped" in a loop.

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


More information about the llvm-branch-commits mailing list