================
@@ -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) {
----------------
bogner wrote:

This reads more simply if you just test the result of the function in the if 
condition. Also, you probably don't need quite that verbose of a name for the 
identifier, so I'd probably write this like:
```c++
  if (!HLSLResourceClassAttr::ConvertStrToResourceClass(Identifier, RC)) {
```

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