[clang] [HLSL] Add `[[hlsl::raw_buffer]]` attribute (PR #107954)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 13 10:49:15 PDT 2024


================
@@ -6168,10 +6168,19 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode {
   struct Attributes {
     // Data gathered from HLSL resource attributes
     llvm::dxil::ResourceClass ResourceClass;
+
+    LLVM_PREFERRED_TYPE(bool)
     uint8_t IsROV : 1;
-    Attributes(llvm::dxil::ResourceClass ResourceClass, bool IsROV)
-        : ResourceClass(ResourceClass), IsROV(IsROV) {}
-    Attributes() : ResourceClass(llvm::dxil::ResourceClass::UAV), IsROV(0) {}
+
+    LLVM_PREFERRED_TYPE(bool)
+    uint8_t RawBuffer : 1;
+
+    Attributes(llvm::dxil::ResourceClass ResourceClass, bool IsROV,
+               bool RawBuffer)
+        : ResourceClass(ResourceClass), IsROV(IsROV), RawBuffer(RawBuffer) {}
+    Attributes()
+        : ResourceClass(llvm::dxil::ResourceClass::UAV), IsROV(false),
+          RawBuffer(false) {}
----------------
damyanp wrote:

Actually, IMO we don't need the default constructor at all - as far as I can tell it's only used in one place in SemaHLSL.cpp and it'd be pretty trivial to remove it.

Then we can be sure that any time someone has constructed one of these Attributes they've specified all the values we care about.

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


More information about the cfe-commits mailing list