================ @@ -7367,6 +7367,75 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, return; } + VarDecl *VD = dyn_cast<VarDecl>(D); + HLSLBufferDecl *BD = dyn_cast<HLSLBufferDecl>(D); + + if (VD || BD) { + llvm::hlsl::ResourceClass RC; + std::string varTy = ""; + if (VD) { + + const Type *Ty = VD->getType()->getPointeeOrArrayElementType(); + if (!Ty) + return; + QualType t = ((ElaboratedType *)Ty)->getNamedType(); + const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); + if (!RD) + return; + + if (auto TDecl = dyn_cast<ClassTemplateSpecializationDecl>(RD)) + RD = TDecl->getSpecializedTemplate()->getTemplatedDecl(); + RD = RD->getCanonicalDecl(); + const auto *Attr = RD->getAttr<HLSLResourceAttr>(); + if (!Attr) + return; + + RC = Attr->getResourceClass(); + varTy = RD->getNameAsString(); + } else { + if (BD->isCBuffer()) { + RC = llvm::hlsl::ResourceClass::CBuffer; + varTy = "cbuffer"; + } else { + RC = llvm::hlsl::ResourceClass::CBuffer; + varTy = "tbuffer"; + } + } + switch (RC) { + case llvm::hlsl::ResourceClass::SRV: { + if (Slot.substr(0, 1) != "t") ---------------- llvm-beanz wrote:
Or we could replace all the `Slot.substr(0,1)` calls just with `Slot[0]` and compare characters instead of strings. https://github.com/llvm/llvm-project/pull/87578 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits