================
@@ -96,24 +96,119 @@ void addRootSignatureMD(llvm::dxbc::RootSignatureVersion
RootSigVer,
RootSignatureValMD->addOperand(MDVals);
}
+// Gived a MemberExpr of a resource or resource array type, find the parent
+// VarDecl of the struct or class instance that contains this resource and
+// build the full resource name based on the member access path.
+//
+// For example, for a member access like "myStructArray[0].memberA",
+// this function will find the VarDecl of "myStructArray" and use the
+// EmbeddedResourceNameBuilder to build the resource name
+// "myStructArray.0.memberA".
+static const VarDecl *findStructResourceParentDeclAndBuildName(
+ const MemberExpr *ME, EmbeddedResourceNameBuilder &NameBuilder) {
+
+ SmallVector<const Expr *> WorkList;
+ const VarDecl *VD = nullptr;
+ const Expr *E = ME;
+
+ for (;;) {
+ if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
+ assert(isa<VarDecl>(DRE->getDecl()) &&
+ "member expr base is not a var decl");
+ VD = cast<VarDecl>(DRE->getDecl());
+ NameBuilder.pushName(VD->getName());
+ break;
+ }
+
+ WorkList.push_back(E);
+ if (const auto *ME = dyn_cast<MemberExpr>(E))
----------------
bob80905 wrote:
Can we choose another variable name for this so it doesn't conflict with the
function parameter?
https://github.com/llvm/llvm-project/pull/187127
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits