================
@@ -437,6 +437,33 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr 
&AL) {
     D->addAttr(NewAttr);
 }
 
+void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) {
+  if (!AL.isArgIdent(0)) {
+    Diag(AL.getLoc(), diag::err_attribute_argument_type)
+        << AL << AANT_ArgumentIdentifier;
+    return;
+  }
+
+  IdentifierLoc *Loc = AL.getArgAsIdent(0);
+  StringRef ResourceClassTypeStrRef = Loc->Ident->getName();
+  SourceLocation ArgLoc = Loc->Loc;
+
+  // Validate.
+  llvm::dxil::ResourceClass RC;
+  bool succ = HLSLResourceClassAttr::ConvertStrToResourceClass(
+      ResourceClassTypeStrRef, RC);
+  if (!succ) {
+    Diag(ArgLoc, diag::warn_attribute_type_not_supported)
+        << "ResourceClass" << ResourceClassTypeStrRef;
+    return;
+  }
+
+  HLSLResourceClassAttr *NewAttr =
+      HLSLResourceClassAttr::Create(getASTContext(), RC, ArgLoc);
+  if (NewAttr)
----------------
bogner wrote:

Can `HLSLResourceClassAttr::Create(...)` fail? Does it actually make sense to 
check if `NewAttr` is null here?

https://github.com/llvm/llvm-project/pull/98419
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to