[llvm-branch-commits] [clang] [HLSL] Use static create methods to initialize resources in arrays (PR #157005)
Chris B via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Sep 15 12:09:48 PDT 2025
================
@@ -110,52 +112,29 @@ static int getTotalArraySize(ASTContext &AST, const clang::Type *Ty) {
return AST.getConstantArrayElementCount(cast<ConstantArrayType>(Ty));
}
-// Find constructor decl for a specific resource record type and binding
-// (implicit vs. explicit). The constructor has 5 parameters.
-// For explicit binding the signature is:
-// void(unsigned, unsigned, int, unsigned, const char *).
-// For implicit binding the signature is:
-// void(unsigned, int, unsigned, unsigned, const char *).
-static CXXConstructorDecl *findResourceConstructorDecl(ASTContext &AST,
- QualType ResTy,
- bool ExplicitBinding) {
- std::array<QualType, 5> ExpParmTypes = {
- AST.UnsignedIntTy, AST.UnsignedIntTy, AST.UnsignedIntTy,
- AST.UnsignedIntTy, AST.getPointerType(AST.CharTy.withConst())};
- ExpParmTypes[ExplicitBinding ? 2 : 1] = AST.IntTy;
-
- CXXRecordDecl *ResDecl = ResTy->getAsCXXRecordDecl();
- for (auto *Ctor : ResDecl->ctors()) {
- if (Ctor->getNumParams() != ExpParmTypes.size())
- continue;
- auto *ParmIt = Ctor->param_begin();
- auto ExpTyIt = ExpParmTypes.begin();
- for (; ParmIt != Ctor->param_end() && ExpTyIt != ExpParmTypes.end();
- ++ParmIt, ++ExpTyIt) {
- if ((*ParmIt)->getType() != *ExpTyIt)
- break;
- }
- if (ParmIt == Ctor->param_end())
- return Ctor;
- }
- llvm_unreachable("did not find constructor for resource class");
-}
-
static Value *buildNameForResource(llvm::StringRef BaseName,
CodeGenModule &CGM) {
llvm::SmallString<64> GlobalName = {BaseName, ".str"};
return CGM.GetAddrOfConstantCString(BaseName.str(), GlobalName.c_str())
.getPointer();
}
-static void createResourceCtorArgs(CodeGenModule &CGM, CXXConstructorDecl *CD,
- llvm::Value *ThisPtr, llvm::Value *Range,
- llvm::Value *Index, StringRef Name,
- HLSLResourceBindingAttr *RBA,
- HLSLVkBindingAttr *VkBinding,
- CallArgList &Args) {
+static CXXMethodDecl *lookupMethod(CXXRecordDecl *Record, StringRef Name,
----------------
llvm-beanz wrote:
We should probably do this with `Sema::LookupSingleName`.
https://github.com/llvm/llvm-project/pull/157005
More information about the llvm-branch-commits
mailing list