[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 1 15:07:53 PDT 2024


================
@@ -112,17 +113,13 @@ struct BuiltinTypeDeclBuilder {
         Ty = Record->getASTContext().getPointerType(
             QualType(TTD->getTypeForDecl(), 0));
     }
-    return addMemberVariable("h", Ty, Access);
-  }
-
-  BuiltinTypeDeclBuilder &annotateHLSLResource(ResourceClass RC,
-                                               ResourceKind RK, bool IsROV) {
-    if (Record->isCompleteDefinition())
-      return *this;
-    Record->addAttr(
-        HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC));
-    Record->addAttr(
-        HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK, IsROV));
+    // add handle member
+    addMemberVariable("h", Ty, Access);
+    // add resource attributes to handle
+    auto *FD = Fields["h"];
----------------
damyanp wrote:

This feels a bit clunky. Would it be possible to maybe have addMemberVariable take a list attributes to add?  I think that this case here is actually the only one that uses addMemberVariable.

This may be moot, since I suspect we're not all that far from being able to move all of this to hlsl.h?

https://github.com/llvm/llvm-project/pull/101433


More information about the cfe-commits mailing list