[clang] [HLSL] [SPIR-V] Add counter member for typed buffer (PR #161414)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 1 13:26:16 PDT 2025


================
@@ -57,6 +57,15 @@ CXXConstructorDecl *lookupCopyConstructor(QualType ResTy) {
       return CD;
   return nullptr;
 }
+
+/// Set up common members and attributes for buffer types
+static bool resourceHasCounter(const CXXRecordDecl *Decl) {
+  StringRef Name = Decl->getName();
+  return Name == "RWStructuredBuffer" || Name == "AppendStructuredBuffer" ||
+         Name == "ConsumeStructuredBuffer" ||
+         Name == "RasterizerOrderedStructuredBuffer";
+}
+
----------------
hekota wrote:

```suggestion
```

It would be best to avoid these string comparisons. Could you add `bool HasCounter` to `HLSLExternalSemaSource::setupBufferType` and pass is to method that adds the handles?

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


More information about the cfe-commits mailing list