[clang] [HLSL] Global resource arrays element access (PR #152454)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 22 16:53:27 PDT 2025
================
@@ -84,6 +85,111 @@ void addRootSignature(llvm::dxbc::RootSignatureVersion RootSigVer,
RootSignatureValMD->addOperand(MDVals);
}
+// Find array variable declaration from nested array subscript AST nodes
+static const ValueDecl *getArrayDecl(const ArraySubscriptExpr *ASE) {
+ const Expr *E = nullptr;
+ while (ASE != nullptr) {
+ E = ASE->getBase()->IgnoreImpCasts();
+ if (!E)
+ return nullptr;
+ ASE = dyn_cast<ArraySubscriptExpr>(E);
+ }
+ if (const DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(E))
+ return DRE->getDecl();
+ return nullptr;
+}
+
+// Get the total size of the array, or -1 if the array is unbounded.
+static int getTotalArraySize(ASTContext &AST, const clang::Type *Ty) {
+ Ty = Ty->getUnqualifiedDesugaredType();
+ assert(Ty->isArrayType() && "expected array type");
+ if (Ty->isIncompleteArrayType())
+ return -1;
+ return AST.getConstantArrayElementCount(cast<ConstantArrayType>(Ty));
----------------
shafik wrote:
Are we sure `Ty` always will be a `ConstantArrayType`?
https://github.com/llvm/llvm-project/pull/152454
More information about the cfe-commits
mailing list