================
@@ -116,12 +116,17 @@ struct BuiltinTypeDeclBuilder {
             QualType(TTD->getTypeForDecl(), 0));
     }
     // add handle member
-    llvm::SmallVector<Attr *, 2> Attrs;
     Attr *ResourceClassAttr =
         HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC);
     Attr *ResourceAttr =
-        HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK, IsROV);
-    addMemberVariable("h", Ty, {ResourceClassAttr, ResourceAttr}, Access);
+        HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK);
+    if (IsROV) {
+      Attr *ROVAttr = HLSLROVAttr::CreateImplicit(Record->getASTContext());
+      addMemberVariable("h", Ty, {ResourceClassAttr, ResourceAttr, ROVAttr},
+                        Access);
+    } else
+      addMemberVariable("h", Ty, {ResourceClassAttr, ResourceAttr}, Access);
----------------
bogner wrote:

Having to deal with each attribute separately like this seems awkward. Doesn't 
it work to simply add the attribute after the fact? Something like:
```suggestion
        HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK);
    addMemberVariable("h", Ty, {ResourceClassAttr, ResourceAttr}, Access);
    if (IsROV)
      Fields["h"]->addAttr(
          HLSLROVAttr::CreateImplicit(Record->getASTContext()));
```

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

Reply via email to