================
@@ -4686,7 +4685,67 @@ bool SemaHLSL::ActOnUninitializedVarDecl(VarDecl *VD) {
return false;
}
-// Return true if everything is ok; returns false if there was an error.
+std::optional<const DeclBindingInfo *> SemaHLSL::inferGlobalBinding(Expr *E) {
+ if (auto *Ternary = dyn_cast<ConditionalOperator>(E)) {
+ auto TrueInfo = inferGlobalBinding(Ternary->getTrueExpr());
+ auto FalseInfo = inferGlobalBinding(Ternary->getFalseExpr());
+ if (!TrueInfo || !FalseInfo)
+ return std::nullopt;
+ if (*TrueInfo != *FalseInfo)
+ return std::nullopt;
+ return TrueInfo;
+ }
+
+ if (auto *ASE = dyn_cast<ArraySubscriptExpr>(E))
+ E = ASE->getBase()->IgnoreParenImpCasts();
+
+ if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParens()))
+ if (VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
+ const Type *Ty = VD->getType()->getUnqualifiedDesugaredType();
+ if (Ty->isArrayType())
+ Ty = Ty->getArrayElementTypeNoTypeQual();
+
+ if (const auto *AttrResType =
+ HLSLAttributedResourceType::findHandleTypeOnResource(Ty)) {
+ ResourceClass RC = AttrResType->getAttrs().ResourceClass;
+ return Bindings.getDeclBindingInfo(VD, RC);
+ }
+ }
+
+ return nullptr;
+}
+
+bool SemaHLSL::trackLocalResource(VarDecl *VD, Expr *E) {
----------------
Icohedron wrote:
The return value is defined in a comment on line 332 of SemaHLSL.h
https://github.com/llvm/llvm-project/pull/182101/changes#diff-4b07fcde6e938519cd1c26c25056957ac3c656f39aaa90255a94b1cc62aeb257R332
https://github.com/llvm/llvm-project/pull/182101
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits